Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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.

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

How to fix “Authentication plugin 'caching_sha2_password' cannot be loaded” with [email protected]

Database creation fails with Authentication plugin 'caching_sha2_password' cannot be loaded error. Above error occurs when I run following command: $ RAILS_ENV=test rake db:create Error message: ...
0
votes
1answer
11 views

Does `config.requre_master_key = false` in production cause any problem?

My application is created by Rails 5.2.2, and it requires master.key when I build assets even though it doesn't use actually. I provide my application as docker image, so I need to build it while ...
0
votes
1answer
14 views

How to hit 'create' instead of 'new' for session in Rails auth pipeline?

I'm at a loss trying to figure out why my Rails auth pipeline only hits new and not create. This causes the login page to re-render and never go to a search page. Would you have a look at my code to ...
0
votes
0answers
7 views

Cast jsonb foreign key on Rails association

Using Rails 6, I'm trying to set a has_many association with a join to a postgres jsonb column. class Form has_many :automation_triggers, foreign_key: "preferences->>'form_id'" end This ...
0
votes
1answer
15 views

How to run commands on ruby-on-rails console inside bash shell script?

I would like to know how to run ruby commands in ruby on rails console inside a shell script ? To be clear: I have a shell script which will connect to ruby on rails console, but unable to run ...
0
votes
1answer
35 views

Best way to process data in a Rails service

I have a reminder service which takes some 'changes requests' and then sends them to a worker queue to perform at a later date. Each 'change request' can either have a 'ten minute before' reminder and ...
0
votes
0answers
12 views

How can I format Global Site Tag in Rails app with Slim

We have an existing, broken, Google Analytics tag in a stale Rails app that we're bringing back to life: // app/views/application/_analytics.html.slim javascript: (function(i,s,o,g,r,a,m){i['...
0
votes
1answer
24 views

Rails Minitest Has Many And Belongs To Model Test ActiveRecord::UnknownPrimaryKey Error

When I try to run minitest with simpleCov, I want the join table model UserMessages to be covered. I have setup fixture, to run test and keep getting an ActiveRecord::UnknownPrimaryKey error. This is ...
1
vote
0answers
22 views

After submitting simple_form i get a blank page in show view

I have created a simple form, the user click on three items and press submit and an email is being send, all of this works. However, when i test it and check the show page, it doesn't show any entered ...
1
vote
1answer
30 views

ActiveRecord - Query with Condition of Last Element in Association

Trying to do a sort of complex query in ActiveRecord right now. Not sure if it's possible to do entirely in ActiveRecord (i.e. without just filtering intermediate results in Rails). I'd like to do as ...
1
vote
0answers
12 views

Heroku Rails 6 multiple connection not working

I have a project running on Rails 6 with multiple database configuration. This is my database.yml configuration default: &default adapter: postgresql encoding: unicode # # For details on ...
0
votes
0answers
9 views

<ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage Error when deploying to Heroku Rails 5.2.3

I'm having a good bit of trouble deploying my React on Rails App to Heroku. I have read and attempted countless posts on how to fix the secret_key_base and rails_master_key issues: ActiveSupport::...
0
votes
1answer
14 views

Rails 6 `protect_from_forgery with: :null_session` not working

In an effort to learn React and using Rails together I am in the process of building a simple "Todo" app. Im using axios to make requests to my rails api within react components. So far everything ...
0
votes
1answer
21 views

Adding role selection to devise sign up form, when role name needs to match role_id (using devise)

I'm new to rails (using rails 6), and I have a question that I didn't see answered on the site for my specific use case. The basic senario is the same as in many question - adding role based ...
0
votes
2answers
36 views

Ruby don't do actions for nil class in if block

How to achieve sth like if params[:filters][:company_name] is present (not nil) then do below actions but if it's nil - skip and do the rest of the code below/outside of this if ? if params[:filters][...
-1
votes
0answers
10 views

Integrate MasterCard payment checkout in Rails [on hold]

hope you all doing well! I'm facing an issue with MasterCard payment integration in my Rails App though, I've read the documentation which showing details about all the java-scripts including, ...
1
vote
0answers
4 views

Dynamic search filter in Rails/Grape to show blank page

In my app after pressing the filter button a search field appears - searching companies by company name. Everything works well but I'm just wondering how to implement scenario where user enters ...
0
votes
0answers
17 views

How to fix ArgumentError in Admin::Payments#show : wrong number of arguments (1 for 0)

I try to add a "show" Interface for payments on Active Admin, so I added this code to my file "app/admin/payments.rb" : actions :index, :show index do ... end show do attributes_table do ...
0
votes
1answer
39 views

Run javascript only if radio button is checked

I want something quite simple for my Rails app: a javascript must be run only if one of the previous radio buttons was checked. What I want exactly is that the user has different radio buttons shown ...
0
votes
0answers
9 views

Issues when adding devise-jwt to a existente User model in Rails

Im trying to add the devise-jwt to an existent app I have. Im adding API endpoints now, and want to use the same Model I have already I added the gem devise-jwt following this article here: https://...
0
votes
1answer
11 views

Replace table tags with p tags if found that result is not found

I am trying to replace the table tag in my html code with p tags denoting that "Result not found!" after searching but I am unsure how. Controller def index if params[:search] @parameter = ...
0
votes
1answer
27 views

Action Controllers and filtering

I'm developing an app where an admin can see a group of users in HTML tables that are filtered by ":platoon => A,B,C,D" All users are stored in a "users model" and I'm trying to have multiple HTML ...
0
votes
1answer
15 views

Use add_foreign_key to reference the same model in rails

I have a model Car I want to create a relation like following belongs_to :primary_car, class_name: 'Car' has_many :secondary_cars, class_name: 'Car', foreign_key: 'primary_car_id' How can I write a ...
2
votes
2answers
50 views

Two way lookup of id vs name ruby

I have a hash in which id is the key and name is the value. Both id and value are unique. Something like this: h[1] = "ABC" h[3] = "DEF" So, if I am given the key of 1, I can easily return a value ...
0
votes
0answers
16 views

Rails Webpacker compile error on Production enviorment

env Rails 6.0.0 Ruby 2.6.0 Amazon Linux2 What enter image description here When I deploy my rails app this error happen ActionView::Template::Error (Webpacker can't find application in /home/web/...
0
votes
1answer
19 views

Why is capybara saying node is obsolete and how to solve?

I have an spec/capybara test which searches for an element and then attempts to run a JS script to scroll the element into view. However, Capybara claims the node is obsolete by the time it attempts ...
0
votes
1answer
39 views

How to access to a shopcart. Couldn't find LineItem with 'id'=2

I'm making a Ecommerce site with rails.Trying to create a shopingcart. When I added , include CurrentCart before_action :set_cart to my application_controller.rb , I got this error. I checked with ...
0
votes
1answer
26 views

Docker on MacOs Errno::ENOENT: No such file or directory - getcwd

I am trying to set up rails 6 with webpacker on docker and I get a weird error once docker up finishes: Errno::ENOENT: No such file or directory - getcwd Once I ssh in the container I get this: ...
0
votes
1answer
18 views

Soft Delete has_and_belongs_to_many association using discard gem

What is the best way to soft delete has_and_belongs_to_many associations using Discard Gem. With this association, there is a join table in database but without actual Ruby on Rails Model. I'll try ...
0
votes
1answer
12 views

Rails 6 multiple databases and query timeout problems when running db:migrate

On MyModel I use configuration which enables db replication to work connects_to database: { writing: :primary, reading: :follower } In some migrations there are queries like: MyModel.update_all(...)...
0
votes
0answers
28 views

How do I keep track of the endpoints being hit for a request?

I am a newbie Web/Rails developer. The codebase(uses multiple docker containers) that I have been provided with is quite vast and when I am assigned issues to solve, it is difficult to understand ...
1
vote
2answers
46 views

How to build a monthly range that takes in account the number of days of each month?

I have a range with a start_date, end_date and I want to get the same day of each month for the whole range, so here starting on the 30th of January I should get the 30th of each month: start_date = ...
0
votes
0answers
6 views

Rails upgrade to 6.0.0 gives undefined method `retry_on' for ActiveStorage::AnalyzeJob:Class

I just upgraded my application to rails 6.0.0 from rails 5.0.0 I am repeatedly getting this error on trying to start rails. I cannot seem to find anything online for this. I also upgraded ruby from 2....
0
votes
1answer
11 views

Libsass: Error: “env(safe-area-inset-right)” is not a number for `max'

I am able to precompile assets in my Rails app. But when I start server and hit url. I get this error
0
votes
1answer
23 views

Linking your github through the aws cloud 9 text editor

I keep getting the error message below when I try to commit my changes to GitHub. Any solution on how to get around this? I'm still a novice when understanding how to push changes I've made to github ...
1
vote
1answer
21 views

how to migrate ruby-sass custom functions to sassc?

How do I migrate this ruby sass custom function to SassC? In a rails project, I just included this module in my application.rb and the likes of my-method would be available in my sass files. The ruby ...
0
votes
1answer
10 views

How do I prevent a redirect loop when forwarding from http to https using rails and elastic beanstalk?

I just installed an ssl certificate in my Rails app and I am now trying to redirect all http traffic to https. It is hosted on AWS elastic beanstalk. I have followed the directions to adjust the nginx ...
1
vote
0answers
14 views

How to configure Jasmine in Rails 6?

How do I configure Jasmine in the Rails 6 environment (where Webpack replaces the asset pipeline for Javascript) so I can test the Javascript modules I've written for my app? I installed the jasmine ...
1
vote
0answers
20 views

Using define_method in Ruby on Rails view helpers

I am creating a component library in Rails using view partials. I would like for each component partial defined in /app/views/components to have a corresponding helper method for rendering the ...
0
votes
1answer
42 views

How to find the original email in a forward using the Mail gem

How do I use the Mail gem for Ruby to extract the original message HTML content/text content from a forwarded email? So far all the examples I see are related to extracting content from replies (not ...
3
votes
1answer
40 views

Transactions isolation level and locking records, disable SELECT on records that are in running transaction

Can I disable SELECT on rows that are been used inside of a transaction? For example, rows in table potatoes are being destroyed in transaction 1, and it takes a long time to do so. In transaction 2,...
1
vote
1answer
28 views

Zeitwerk, require_dependency and splitting Ruby classes into a few files

Before Rails 6 there was a simple way to split any Ruby class into multiple files without introducing any additional modules or concerns. It was quite useful for those God classes which happened to be ...
0
votes
3answers
44 views

Show records only belonging to that user ruby on rails

I have the following code <div class="container mt-4"> <div class="card"> <div class="card-header"> <h5>Name: <%= @user['name'] %> | Username: <%= @user['...
0
votes
1answer
13 views

How can I use a Rails helper inside Jbuilder with the Gon gem?

I'm using Jbuilder and Gon to structure my JSON responses into variables and pass them to my JS front-end. In the Jbuilder files, I'd like to access the helper methods I'm using from the Money-Rails ...
0
votes
2answers
29 views

display nested JSON in ruby on rails

I believe this is going to be an easy fix but everything I'm trying isn't working. I'm getting data from an external API and I'm looking at display the data after matching the ids. The data is JSON ...
0
votes
0answers
33 views

i386 arch error installing old scrypt gem version with OS Catalina 10.15

I'm trying to install an old gem version for an old project after a fresh install of OS X 10.15 Catalina and XCode Command Line Tools and Xcode 11.0. The gem I'm trying to install is scrypt, version 1....
0
votes
1answer
20 views

Can not create rails app because of path problems

When I try to create a new rails app this error fires in the console: bash: /usr/local/bin/rails: /usr/bin/ruby2.5: bad interpreter: No such file or directory anyway when I write this line it goes ...
1
vote
1answer
16 views

Error using a button in view to trigger action

Rails 5.2 In my routes.rb, I have the following: put 'lights/reset_node', to: 'lights#reset_node' When I run rake routes, I get: lights_reset_node PUT /lights/reset_node(.:format) lights#...
3
votes
1answer
30 views

block_given? always returns true in erb templates

In Rails 5.2.3, I need to render a partial which takes an optional block. # users/_user.html.erb ... <% if block_given? %> <%= yield %> <% else %> <h1>Goodbye world</h1&...
1
vote
1answer
34 views

display other data within `each` ruby on rails

I have an application where I'm displaying albums and users I'm currently outputting the albums, <main role="main" class="flex-shrink-0"> <div class="container"> <h1 class="mt-5"...