Questions tagged [ruby-on-rails-5]

For issues specific to version 5.x.y of Rails. If your question applies to Ruby on Rails in general, use the tag [ruby-on-rails].

Ruby on Rails 5 is the previous major revision of Ruby on Rails, "an open-source web framework that's optimized for programmer happiness and sustainable productivity."

Multiple sub-versions have been released, namely 5.1 and 5.2. Questions regarding specific sub-versions of Ruby on Rails 5 can also be asked on the appropriate tags:

Resources:

See also:

9415 questions
2
votes
1 answer

How to use an environment variable in a route in rails 5

I can make environment variables accessible to the app locally with a .env file Problem is, I can't work out how to use the variable in a route I have tried variations of get 'v1/packages<%= ENV["key1"] %>' => 'flatfiles#raw' Unfortunately this…
stevec
  • 41,291
  • 27
  • 223
  • 311
2
votes
0 answers

current_user is nil in user controller's show action

I took over a rails project where an admin can create users. The authentication is done with the devise gem. Once the normal user is logged in, everything works fine. The current_user variable holds my user. But when I try to access the user's…
Clara
  • 2,677
  • 4
  • 16
  • 31
2
votes
1 answer

Spring error when creating a new model in Rails

I'm trying to create a new model in a Rails API-only app but I geta "cannot load such file" error message: /Users/max/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork': cannot load such file --…
MaxRah
  • 243
  • 1
  • 6
  • 21
2
votes
3 answers

Rails 5.2.3 converting all params datatype to string when testing using rspec

I am using rails 5.2.3 and testing using rspec-rails (3.8.2), when I send request to rails like this let(:params) do { down_payment: 10_000, asking_price: 100_000, payment_schedule: 'weekly', amortization_period: 5 …
icn
  • 17,126
  • 39
  • 105
  • 141
2
votes
3 answers

Rails 5.2 rspec - How to test if a model is actually using a custom validator?

I have created a custom validator which has it's own specific unit tests to check that it works. Using should-matchers there was a suggestion to add a validates_with matcher, so you could write: subject.validates_with(:custom_validator) Quite…
rmcsharry
  • 5,363
  • 6
  • 65
  • 108
2
votes
1 answer

Rails: Bundler could not find compatible versions for gem "activerecord":

Hi I am trying to use the gem acts_as_bookable I get the issue when trying to bundle install Bundler could not find compatible versions for gem "activerecord": In Gemfile: acts_as_bookable was resolved to 0.1.2, which depends on …
Joe Bloggos
  • 889
  • 7
  • 24
2
votes
2 answers

Activestorage: get S3 key (not Rails blob key)

I'm using Activestorage. I want to retrieve the S3 key to hand off to a microservice. I don't want to download the blob or anything like that in the Rails app, I just want to provide the file path/key in an API request. service_url is overkill…
t56k
  • 6,769
  • 9
  • 52
  • 115
2
votes
1 answer

How to do optional nested forms with form_for in rails 5

I have the following form with nested attributes. Which is working correctly. However I want to make the points optional, meaning if you leave the summary field blank the form should still submit and create a debate without creating a point. I have…
Jamesla
  • 1,378
  • 7
  • 31
  • 62
2
votes
2 answers

Switch to a different version of ruby using homebrew

I migrated my MacBook using Migration Assistant. I have two rails apps I was working on my previous laptop and now when I try working on those apps on my new laptop one them works properly(Restaurant App) and in the other(Quiz App) when I try to…
User7777
  • 289
  • 4
  • 19
2
votes
1 answer

Model.group(:id) throws an error "Select list is not in GROUP BY clause contains non aggregated column "id"

I am using Model.group(:category) in order to get unique records based on category field in Rails 5 application. Table data: id catgeory description 1 abc test 2 abc test1 3 abc test2 4 xyz test 5 xyz …
Veda
  • 577
  • 1
  • 6
  • 22
2
votes
1 answer

Rails 5 ActionController::InvalidAuthenticityToken on Production Enviroment Nginx

On Rails 5.2, SSL enviroment, running as reverse_proxy with Nginx, whenever I submit a form I get the error: HTTP Origin header (https://agro2business.com.br) didn't match request.base_url (https://agro2business.com.br,…
Pavarine
  • 637
  • 3
  • 15
  • 30
2
votes
2 answers

ModelName.real in models of Rails application

I have checked one code where in the model its was written an association . has_many :association_name, -> { merge(ModelName.real) }, class_name: ModelName.to_s I would be great if some one explain it.
Rakesh
  • 793
  • 4
  • 22
2
votes
0 answers

Upgrading rails4 to 5.0.0 and getting dependency error for actionpack, activemodel

I am upgrading my rails app from rails 4 to rails 5.0.0 I have fixed most dependency issues except the following: Bundler could not find compatible versions for gem "actionpack": In Gemfile: actionpack rails (= 5.0.0) was resolved to 5.0.0,…
2
votes
0 answers

Resque::DirtyExit Child process received unhandled signal

My background jobs are failing randomly with the exception Resque::DirtyExit Child process received unhandled signal. After I restart the server they work for some time and then start failing. I suspect something else is going on with my system but…
NST
  • 724
  • 9
  • 20
2
votes
2 answers

Stripe Payment Error: Must provide source or customer

I've been trying to implement a payment method for a shopping cart using card information attached to the user via a subscription model. And while the latter works fine, whenever I attempt to create a charge for the cart, I get the "Must provide…
Grasshopper27
  • 113
  • 1
  • 11
1 2 3
99
100