Questions tagged [ruby-on-rails]

Ruby on Rails is an open source full-stack web application framework written in Ruby. It follows the popular MVC framework model and is known for its "convention over configuration" approach to application development.

1
vote
1answer
10 views

Rails model has_many association to the same model

I have two models: Category and Subcategory And I can have situation that Subcategory will include more Subcategories How Can I do it with rails associations? Now my code: category.rb class ...
-1
votes
0answers
15 views

Custom gem idea [on hold]

I'm creating a logistics web app and I would like assistance in ideas for a custom gem for a college project. A custom gem is a requirement of the project. The custom gem has to be functional to the ...
0
votes
0answers
9 views

How to convert a simple postgresql table to hypertable or timescale db table using created_at for indexing

The problem is that when I want to convert a simple Postgresql table to timescaledb table or hypertable using created_at table field for indexing then it will show this error. The table name is orders....
0
votes
1answer
17 views

RAILS: How to select fields from associated table with grouping and create a hash from result?

I would like to create an active record query and store the result in a hash which includes summary information from associated tables as follows. Here is the tables and associations: Post ...
0
votes
1answer
14 views

Rails: Why is my model nil even though my migration creates the table?

I recently decided to change the name of a model. So I dropped the DB calling rails db:drop. Using sublime text editor I did a find & replace for the model name, and I renamed all relevant ...
1
vote
2answers
15 views

Adding extra fields to devise token auth user sign up

I have a signup form for devise-token-auth. I would like users to enter a username as well on the signup form. The username column exists in the database but the controller rejects it Unpermitted ...
0
votes
1answer
11 views

How to display all categories for an industry which has sub_categories into grouped_collection_select in Rails

I have three models. Industry, ProductCategory and ProductSubCategory. And the association between them is like following: class Industry has_many :product_categories end class ProductCategory ...
0
votes
1answer
25 views

Axios post works, Axios put doesn't get past preload request

Axios put won't get past preload request, but if I change it to post, the request does send. This is my code. In the network tab OPTIONS shows, but on post, it sends OPTIONS and POST. handleSubmit()...
-5
votes
0answers
37 views

How to fix this problem in ubuntu 18.04 when running it

/usr/local/rvm/gems/ruby-2.6.1/gems/activesupport-4.2.5.1/lib/active_support/core_ext/object/duplicable.rb:85: warning: BigDecimal.new is deprecated; use BigDecimal() method instead. /usr/local/rvm/...
0
votes
0answers
22 views

Multiple HTML forms on one page with multiple stripe.js files?

I have multiple html POST forms on one page for Stripe.. The issue is I can only POST the last form on the page. If i try submitting the former ones, it will not work and give me errors (on the ...
0
votes
1answer
15 views

How to fix StatementInvalid error with Stripe

I'm working on payment system with Stripe. I have to search customer after receiving stripe webhook. But this error below occurs. ActiveRecord::StatementInvalid (SQLite3::SQLException: near "'...
0
votes
0answers
16 views

Como relacionar o Sublime com o terminal do Ubuntu instalado no Windows? [on hold]

Galera, estou trabalhando com Ruby on Rails no Windows, e tive que instalar o "terminal" do Ubuntu na minha máquina, até aí tudo bem, o Banco de Dados tava se relacionando, o servidor tava subindo e ...
0
votes
0answers
32 views

How to conditionally load javascript files based on tab toggled?

I want, depending on the radio selected, for the javascript associated with the radio to function, and when its not selected or deselected, to not be functioning. HTML for tabs and radios: <nav&...
0
votes
0answers
17 views

Using Rails acts_as_votable_gem with AJAX

I'm trying to have the votes updated without the page reloading, and I have it so when the upvote is clicked on, it does update it in the DB and the page does not reload but the updated score is not ...
0
votes
2answers
39 views

How to display a list of multiple model

I'm working on a social networking media like Facebook. Users can create daily posts and events. In timeline, I want to display a combined list of @post and @event. Can I build that on Rails? How ...
0
votes
0answers
18 views

Rails 5.2+: Retrieving a resource and attributes from parent record 4 associations away

I'm trying to figure out how to optimize this SQL query to avoid n+1 situations. I have some associations setup like this: a has_many b b has_many c c has_many d d has_many e I'm returning a ...
1
vote
1answer
24 views

Rails Join not showing fields from related table [duplicate]

Profile.joins(:course) does not display the :course fields. I have tried Profile.joins(:course).select('profiles.*,courses.*') and it appears in the select, but not the from command, so none of the ...
1
vote
0answers
19 views

Rails routes choose between 403 and 404 page

I use devise to authenticate in my Rails application and my Routes are defined as follows: App::Application.Routes.Draw do namespace :api do ... ... authenticated :user do ...
0
votes
1answer
17 views

Deleting (Destroying) Class Object That Belongs To Another Class Object

I am attempting to delete a class object that belongs to another class object but the destroy method is actually deleting the class object that has_many rather than deleting the singled out belongs_to ...
0
votes
0answers
10 views

Ruby on Rails SSO implementation using gem devise_saml_authenticatable and Ping Identity (ping federate)

For my rails project I'm implementing SSO using SAML. The gems for managing users and signing them in/out are devise and devise_saml_authenticatable. My User.rb has the following declaration for ...
0
votes
2answers
18 views

Rails acts_as_votable using AJAX to stop page reloads

I'm trying to be able to upvote using acts_as_votable without the page reloading but I'm not sure how to change the routes to make it work Controller def upvote @video = Video.find(params[:id]) ...
0
votes
2answers
43 views

How does ActiveRecord::Relation get added to Rails' models and why does each model have individual Relation class?

Suppose I have a Rails model: class Project < ActiveRecord::Base In the Rails console: > Project.all => #<ActiveRecord::Relation []> That seems reasonable. However, > Project....
0
votes
0answers
17 views

Cookie Cannot be expired by rails

I've been trying to use the rails ActionController cookies tool to expire a cookie that is set by a different application on the same subdomain. Essentially a legacy app sets a cookie called "ORG_SID"...
0
votes
2answers
20 views

How to add an element into an array of a Serialize Field using Ruby on Rails

I have a field call query_data defined as text in my MySQL database. In my model I defined this field as serialize :query_data, JSON. The JSON format I would like to save and retrieve look like ...
0
votes
0answers
6 views

Implementing omniauth-microsoft_graph with Devise in Rails

Hi im trying to implement authentication with office365 for an app with Devise 4.6.1 in rails 5.2. I was thinking about using omniauth-microsoft_graph is this the correct gem for the job? If so, how ...
0
votes
0answers
14 views

Rails minitest returning “NoMethodError: undefined method `make_response!'”

I have a couple tests that run fine independently rails t test/controllers/briefs_controller_test.rb Running via Spring preloader in process 24174 Run options: --seed 46330 # Running: .................
0
votes
1answer
24 views

Rails 5.2 - Sub-menus don't keep opened (Turbolink ?)

I have this sidebar and I am having troubles to open sub-menus. When I click on a sidebar-dropdown it opens and closes immediately. The more I click the less it opens, and then it doesn't open ...
0
votes
1answer
12 views

request active storage image show only one not all images

As Rookie Rails, i am able to get all images to display on the html.erb as using model as has_many_attached :images but i have tried many different way like this code below <div class="row"> ...
0
votes
1answer
24 views

Is it possible to access a Module from within a haml file?

I'd like to create sort my helpers into sub-modules, in order to make the code cleaner. For example, I'd like to implement something like this: = UI.spawn_component(UI.alert, UI.error, "message") I ...
0
votes
1answer
17 views

Defining attributes at runtime based on data from related object

I'm building an application where users are part of an Organisation. An organisation has many Lists, which in turn have many ListItems. Now, I would like for admin users to be able to specify which ...
0
votes
2answers
12 views

Rails, JWT : Why is current_user called/executed as frequent as the times it is stated in the erb template?

application_conroller.rb def current_user p 'current_user' user = decode_jwt(cookies.permanent[:jwt_token] @current_user ||= user end then, I have some.html.erb <%=current_user.id%&...
0
votes
0answers
17 views

In Rails 5 can you tell left_joins what foreign key to use with model?

I have a camp registration project where camper can sign up for two class to take a camper. I have it setup with a camper model and camp classes model. I am using has_many/belongs_to to link the ...
-1
votes
1answer
28 views

Michael Hartl Ruby on Rails Tutorial Chapter 9 Failing Tests

I tried looking for an answer to this question, but to no avail. I'm getting this error message when I run rails test. 1) Error: UsersLoginTest#...
0
votes
0answers
10 views

Russian doll caching vs includes(:association)

I am wondering how to deal with “unneccessary SQL request if partial is cached” => An SQL request on thing.user is made in the partial. I can avoid it by using @things.includes(:user) But the thing ...
0
votes
1answer
21 views

Markdown Validator

I am migrating a discussion forum from OSQA to Discourse. I am stuck at one problem in doing so. Since its a discussion forum for coding related topics, much of the posts contains code snippets. ...
0
votes
1answer
17 views

Aws Rekognition Text detect

I have been trying to use the Rekognition API to detect text in an image. I have enabled full access for the Rekognition API (IAM), and am configuring the credentials and region in config of my app. ...
0
votes
1answer
13 views

Rails rendering file as HTML instead of JS. Using Ransack Gem

Having a nightmare with this one and think i'm going to go crazy. It must be something simple. I have ransack working on my listings#index. It renders the results in a JS partial no problem using ...
0
votes
3answers
30 views

Validating against blank password in Rails

I added password password validations to my User model: validates :password, presence: true validates :password, confirmation: { case_sensitive: true } but then when I wanted to update other fields ...
0
votes
2answers
19 views

rails migration : check existence of multiple columns

I have a company table and I want to check the existence of multiple column to remove them. class RemoveSettingsReportColumnsFromCompany < ActiveRecord::Migration[5.1] def change if ...
0
votes
3answers
39 views

Rails global function available to all objects

I'd like to make a function current_order_week that would be available globally throughout my app and could be called similarly to something like current_user. I don't want to have to include it in a ...
0
votes
0answers
16 views

Frozen Error when trying to run rails application

I am running a rails application and when it now shows the below error in console and web application is not loading. FrozenError (can't modify frozen fatal): Please help as I don't even ...
0
votes
0answers
13 views

Redmine 4.x Plugin install

Have update my redmine 3.x to 4.0.2 but work with no plugins. Im try to install one by one the plugins but is not work all plugins have error. This is a error from easy_wbs : bundle exec rake ...
0
votes
2answers
31 views

Parameter in find method

I'm following a guide to Ruby on Rails and there is something I don't understand. I have this model called Comment which belongs_to another two models, called User and Book. This model's controller, ...
0
votes
1answer
17 views

Deployed digitalocean app isn't reading environment variables

I have deployed an app to digitalocean using the Ruby on Rails image. It is set up by default with a user called rails. My rails.service file looks like: [Unit] Description=OneMathsExamQuestions ...
0
votes
1answer
13 views

Rails 5: Restrict HTTParty query to current_user

I'm currently working on the implementation of Typeform's API. I'm able to fetch the responses, but I need to display the responses assigend to the user. When a typeform is submitted a hidden_field ...
0
votes
0answers
24 views

Rails 5 remote form redirect to different pages using virtual attribute

I have a remote: true form in my Rails 5 app and I'd like to redirect to different pages depending on when it's used. I've tried adding a :redirect_to virtual attribute: <%= a.input :...
0
votes
1answer
19 views

Rails - Using Posts#Index View to show only 'Liked' Posts

Since the index view for posts has the same code, I have an action in the Posts controller #liked, which save all of the current_user's liked posts. I am trying to redirect_to posts_path(@posts), but ...
0
votes
1answer
26 views

How to generate xml using nokogiri builder

I am trying to build an xml file using nokogiri in rails. The xml is of the below format. <ServiceIncident> <Incident> <Abstract>linux_bpac_endpoint_scan_v01</Abstract> ...
0
votes
0answers
16 views

looking for simple rails profiler that computes count and length

I cannot seem to find a good profiler for rails. What I want is something that looks through all of my code (not any core code) and i want to know two things 1) the number of times a function is ...
0
votes
2answers
20 views

(PG::UndefinedObject: ERROR: type “hstore” does not exist) in rails production

I have a element with type hstore, during the migration for schema it does not work even though the database is enabled with hstore extension.I get a (PG::UndefinedObject: ERROR: type "hstore" does ...

http://mssss.yulina-kosm.ru