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
237
votes
10 answers

Rails - How to use a Helper Inside a Controller

While I realize you are supposed to use a helper inside a view, I need a helper in my controller as I'm building a JSON object to return. It goes a little like this: def xxxxx @comments = Array.new @c_comments.each do |comment| @comments…
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
152
votes
12 answers

Load lib files in production

I've upgraded one of my apps from Rails 4.2.6 to Rails 5.0.0. The Upgrade Guide says, that the Autoload feature is now disabled in production by default. Now I always get an error on my production server since I load all lib files with autoload in…
Tobias
  • 4,523
  • 2
  • 20
  • 40
127
votes
20 answers

Bundler: You must use Bundler 2 or greater with this lockfile

I'm working with heroku and every time I try to push my app this message shows out: remote: Compressing source files... done. remote: Building source: remote: remote: -----> Ruby app detected remote: remote: ! remote: ! You must use Bundler…
Pedro
  • 1,352
  • 2
  • 10
  • 22
125
votes
1 answer

The ":nothing" option is deprecated and will be removed in Rails 5.1

This code in rails 5 class PagesController < ApplicationController def action render nothing: true end end results in the following deprecation warning DEPRECATION WARNING: :nothing` option is deprecated and will be removed in Rails 5.1.…
Linus Oleander
  • 17,746
  • 15
  • 69
  • 102
113
votes
5 answers

Rails 5: ActiveRecord OR query

How do you do an or query in Rails 5 ActiveRecord? Also, is it possible to chain or with where in ActiveRecord queries?
100
votes
1 answer

rails db:migrate vs rake db:migrate

I noticed that when generating data migration in Rails 5, some people use rails db:migrate over rake db:migrate. Can someone explain the difference between the rails and the rake command in database migration? Does it mean the rake command is…
York Wang
  • 1,909
  • 5
  • 15
  • 27
96
votes
5 answers

warning: constant ::Fixnum is deprecated When generating new model

I've tried to find some solution for this, but I really couldn't find anything related with the errors that is appearing to me when I run the rails command: rails generate model Book title:string summary:text…
user7374147
  • 963
  • 1
  • 6
  • 6
94
votes
9 answers

Rails 5: how to use $(document).ready() with turbo-links

Turbolinks prevents normal $(document).ready() events from firing on all page visits besides the initial load, as discussed here and here. None of the solutions in the linked answers work with Rails 5, though. How can I run code on each page visit…
AndrewH
  • 3,418
  • 2
  • 15
  • 27
90
votes
1 answer

What to use instead of `render :text` (and `render nothing: true`) in rails 5.1 and later?

Rails 5.1 removes a whole load of previously deprecated methods. Among them is the old friend render :text. It was very useful when you need to render some text, but don't want the overhead of a view template. Examples: render text: "ok" render…
Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
79
votes
2 answers

What is the use of secret_key_base in rails 4

I am new to Rails 4, and do not understand the use of secret_key_base under config/secrets.yml in Rails 4. Can you please explain this concept? Also, when I am working in the production environment, I am prompted to set the secret_key with…
77
votes
4 answers

Why does Rails fails to boot with "Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)"?

After bundle update my Rails app fails to boot with: Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
Kris
  • 19,188
  • 9
  • 91
  • 111
74
votes
2 answers

ActiveRecord OR query Hash notation

I know there are 3 main notations for supplying arguments to the where ActiveRecord method: Pure String Array Hash Specifying and for the where method is straight forward: # Pure String notation Person.where("name = 'Neil' AND age = 27") # Array…
72
votes
11 answers

LoadError: Could not load the 'listen' gem (Rails 5)

I've got an API mode Rails 5 app that won't let me run rake routes or rails s. The error I get is: $ rake routes rake aborted! LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your…
lostphilosopher
  • 4,361
  • 4
  • 28
  • 39
72
votes
2 answers

Why Rails 5 uses ApplicationRecord instead of ActiveRecord::Base?

We know that Rails 5 added ApplicationRecord as an abstract class which was inherited by our models (ActiveRecord). But basically, I think every technical requirement we do with ApplicationRecord, we can also do with ActiveRecord::Base. For…
Hieu Pham
  • 6,577
  • 2
  • 30
  • 50
1
2 3
99 100