Questions tagged [ruby-on-rails-5.1]

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

Ruby on Rails 5.1, "an open-source web framework that's optimized for programmer happiness and sustainable productivity." Rails 5.1 brings a bunch of new features and improvements over older Rails versions.

Major Features

  • Yarn Support
  • Webpack
  • Encrypted secrets

See Ruby on Rails 5.1 Release Notes for more information.

Resources

Related tags

397 questions
42
votes
5 answers

Rails 5.1: "unknown firstpos: NilClass" - Issue reloading application

Following an upgrade from Rails 5.0 to 5.1 I'm getting this error anytime the app reloads, either from code changes during rails server or if I call reload! from the console. 13:53$ rc Loading development environment (Rails 5.1.1) 2.3.1 :001 >…
JP Duffy
  • 1,307
  • 1
  • 11
  • 18
40
votes
3 answers

Undefined method for `before_filter'

I am running into the following error despite the method being clearly defined in the next line. undefined method `before_filter' for AuthorsController:Class I am following this tutorial. Code snippet as follows: authors_controller.rb class…
Carrein
  • 3,231
  • 7
  • 36
  • 77
39
votes
8 answers

The asset "logo.png" is not present in the asset pipeline

In Rails 5.1.3 I change logo file in app/assets/images Then error don't know what to fix. Any one know ? The asset "logo.png" is not present in the asset pipeline. Already try restart rails, rails clean, rails or rails assets:precompile Here my…
PKul
  • 1,691
  • 2
  • 21
  • 41
30
votes
4 answers

Nested Resources w/ Rails 5.1 form_with

Per this pull request I can see that an array should be passed to form_with's model param. However, when I supply the following: <%= form_with(model: [@trip, @activity], local: true) do |f| %> ... <% end %> Rails will return -…
colincr
  • 550
  • 1
  • 7
  • 25
29
votes
2 answers

Why is my rails db:migrate not working?

I typed in rails db:migrate and received the following error. I googled and someone said something like changing the Migration version from [4.2] to [5.1] but it still has not worked. rails db:migrate rails aborted! StandardError: An error has…
jose tanaka
  • 489
  • 1
  • 4
  • 9
22
votes
3 answers

Set local: true as default for form_with in Rails 5

I'm working on a project where we won't be using ajax calls for submitting the forms, so I need to put local: true in every form in the project, as indicated in the rails docs: :local - By default form submits are remote and unobstrusive XHRs.…
Ramses
  • 996
  • 4
  • 12
  • 28
22
votes
1 answer

Rails 5 - Uncaught Error: Bootstrap dropdown require Popper.js

So, I was struggling at the last few hours about getting my bootstrap navbar to work in my rails 5.1.3 app. No success. I found a console error saying Uncaught Error: Bootstrap dropdown require Popper.js I was aware that bootstrap was dropping…
19
votes
5 answers

How to properly test ActiveJob's retry_on method with rspec?

I have been attempting to test this method for the past few days with no luck. Another thing I'd like to be able to do is rescue the error that bubbles up after the final retry attempt is made. Please see my comments and code snippets below. Source…
19
votes
5 answers

Where should I place my middleware file for Rails 5.1?

Previously I had my middleware under lib/middleware/my_middle_ware.rb However when doing this, config.middleware.use MyMiddleWare I receive a NameError: uninitialized constant Where is rails looking for the middleware?
Siva
  • 1,256
  • 3
  • 13
  • 29
17
votes
2 answers

Testing POST ActionDispatch::Http::Parameters::ParseError: 765

It says there's an unexpected token in my params. "ActionDispatch::Http::Parameters::ParseError: 765: unexpected token at 'conversation_identifier[participant_list][]=2&conversation_identifier[participant_list][]=1" A version of the test with magic…
Adamantish
  • 1,888
  • 2
  • 20
  • 23
17
votes
4 answers

Rails 5.1.1 deprecation warning changed_attributes

I've just upgraded from Rails 5.0.0 to 5.1.1 and started getting a ton of deprecation warnings like this: DEPRECATION WARNING: The behavior of changed_attributes inside of after callbacks will be changing in the next version of Rails. The new …
Almaron
  • 4,127
  • 6
  • 26
  • 48
16
votes
3 answers

Rails 5.1 webpacker "import" a .js.erb file?

From app/javascript/packs/application.js I'm trying to import "../foo" where the file is foo.js.erb. Webpacker and yarn are working great for other imports in application.js, for example import "../bar" when that file is bar.js but if I try with a…
eagspoo
  • 2,095
  • 3
  • 22
  • 31
15
votes
1 answer

Rails migration, references `unique: true` isn't generating `unique: true` in schema causing constancy_fail check to fail

I have the following migration class CreateBooking < ActiveRecord::Migration[5.1] def change create_table :bookings do |t| t.integer :day_period, default: 0 t.references :service, foreign_key: true, unique: true, dependent:…
Thermatix
  • 2,757
  • 21
  • 51
15
votes
1 answer

undefined method `map' for # Rails 5.1

I am upgrading my rails application from 3.2.2 to 5.1.4. I am gettign error on map method by using on params directly. Error: undefined method `map' for ActionController::Parameters On following line. @assignments= params[:assignments].map {|_k,…
Zia Qamar
  • 1,694
  • 1
  • 15
  • 35
15
votes
1 answer

Asset application.css is not declared but it is declared in manifest

I got this error: ActionView::Template::Error (Asset `application.css` was not declared to be precompiled in production. Declare links to your assets in `app/assets/config/manifest.js`. //= link application.css and restart your server): Rails…
1
2 3
26 27