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
71
votes
7 answers

Rails 5, Rspec: Environment data not found in the schema

After upgrading a Rails app to Rails 5, running RSpec tests gives me the following error: rails aborted! ActiveRecord::NoEnvironmentInSchemaError: Environment data not found in the schema. To resolve this issue, run: bin/rails…
steel
  • 11,883
  • 7
  • 72
  • 109
70
votes
1 answer

Controller spec unknown keyword: id

I have simple action show def show @field = Field.find_by(params[:id]) end and i want write spec for it require 'spec_helper' RSpec.describe FieldsController, type: :controller do let(:field) { create(:field) } it 'should show field'…
user
  • 1,341
  • 2
  • 17
  • 28
68
votes
1 answer

Rails: difference between ENV.fetch() and ENV[]

What is the difference between these two syntax: ENV.fetch("MY_VAR") ENV['MY_VAR'] I've seen Rails 5 use both versions of these in difference places and can't figure out what the difference is (apart from the first one being more characters to…
Winker
  • 805
  • 2
  • 7
  • 9
63
votes
5 answers

Rails: How to disable turbolinks in Rails 5?

It's a constant headache when dealing with websockets, and it kills my performance in addition to adding bugs. Since ActionCable is the whole reason I upgraded I'd very much like to get rid of it completely.
GlyphGryph
  • 4,714
  • 4
  • 32
  • 43
60
votes
2 answers

Undefined instance method "respond_to" in Rails 5 API Controller

In rails 5 created with --api I have an error NoMethodError (undefined method `respond_to' for # Did you mean? respond_to?): However, in the documentation for rails 4.2 it says…
Incerteza
  • 32,326
  • 47
  • 154
  • 261
51
votes
8 answers

Rails: How to fix "Missing secret_key_base for 'production' environment"

I simply can't get past the message: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit` (ArgumentError) I have Rails 5.2.0, and ran EDITOR=vim rails credentials:edit and inside: production: …
Sylar
  • 11,422
  • 25
  • 93
  • 166
47
votes
2 answers

Rails 5.2 with master.key - Heroku deployment

Rails 5.2 introduces the encrypted secrets feature through the usage of the awesome credentials.yml. But I'm struggling to get it to work with Heroku. Is there any Strategy available right now to deploy a Rails 5.2 App to Heroku?
Bergrebell
  • 4,263
  • 4
  • 40
  • 53
44
votes
6 answers

Relation passed to #or must be structurally compatible. Incompatible values: [:references]

I have two queries, I need an or between them, i.e. I want results that are returned by either the first or the second query. First query is a simple where() which gets all available items. @items = @items.where(available: true) Second includes a…
43
votes
4 answers

Rails 5: unable to retrieve hash values from parameter

I'm running into a strange issue. undefined method `values' for # is the error I get, when I assign a variable to a param hash, and try to get it's values. attributes =…
42
votes
1 answer

How do I resolve the deprecation warning "Method to_hash is deprecated and will be removed in Rails 5.1"

I'm trying to update to Rails 5, I'm getting the following deprecation warning: DEPRECATION WARNING: Method to_hash is deprecated and will be removed in Rails 5.1, as ActionController::Parameters no longer inherits from hash. Using this deprecated…
Hakanai
  • 12,010
  • 10
  • 62
  • 132
42
votes
7 answers

How can I make cookies secure (https-only) by default in rails?

In a Rails controller, I can set a cookie like this: cookies[:foo] = "bar" And specify that the "secure" (https-only) flag be on like this: cookies[:foo, :secure => true] = "bar" :secure is false by default. How can I have cookies be secure by…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
42
votes
3 answers

Request origin not allowed: http://localhost:3001 when using Rails5 and ActionCable

Having server issues with an app in Rails 5.0.0.beta2 trying to use ActionCable. Using localhost:3000 works fine, as that is what most of ActionCable defaults to. But if I try to run the rails server on port 3001, it gives me Request origin not…
daybreaker
  • 1,320
  • 1
  • 10
  • 17
40
votes
1 answer

Is DatabaseCleaner still necessary with Rails system specs?

From all that I've read about Rails 5.1 new system specs my understanding was that Rails now handles database transactions internally. From Rspec's blog: "[previously] your tests and your code under test cannot share a database transaction, and so…
Andy Harvey
  • 12,333
  • 17
  • 93
  • 185
39
votes
4 answers

Docker: Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

I am getting issues while setup and run the docker instance on my local system with Ruby on Rail. Please see my docker configuration files:- Dockerfile FROM ruby:2.3.1 RUN useradd -ms /bin/bash web RUN apt-get update -qq && apt-get install -y…
39
votes
5 answers

require_tree argument must be a directory in a Rails 5 upgraded app

I just upgraded my app from Rails 4.2.7 to Rails 5.0.0.1. I used RailsDiff to make sure I had everything covered and I believe I did. So far everything has worked well up until the loading of my app. Now I am seeing this…
marcamillion
  • 32,933
  • 55
  • 189
  • 380