Questions tagged [ruby-on-rails-4.2]

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

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

See Ruby on Rails 4.2 Release Notes for more information.

Resources

Related tags

707 questions
151
votes
10 answers

Rails 4 - Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded

In my gemfile I have: gem 'mysql2' My database.yml is as follows: default: &default adapter: mysql2 database: <%= ENV['db_name'] %> username: <%= ENV['db_user'] %> password: <%= ENV['db_pass'] %> host: <%= ENV['db_host'] %> pool:…
89
votes
9 answers

How to change the default binding ip of Rails 4.2 development server?

After upgrading our team's rails application to 4.2, as the release note mentioned, the default ip rails server binds to is changed to localhost from 0.0.0.0. We develop with Vagrant, and want the development server to be accessible directly from…
Huang Tao
  • 2,156
  • 2
  • 25
  • 31
65
votes
5 answers

Why doesn't Rails autoload classes from app/services?

I'm working on a Rails 4.2 app and have just added app/services/fetch_artists.rb to the structure. Inside this file, I have defined a class FetchArtists; end. When trying to run rails r 'FetchArtists' it gives me a NameError: uninitialized constant…
linkyndy
  • 14,398
  • 14
  • 96
  • 180
52
votes
3 answers

Add nullable foreign key in Rails

Referencing to Rails 4.2 add_foreign_key support: # add a foreign key to `articles.author_id` referencing `authors.id` add_foreign_key :articles, :authors How to create a nullable foreign key constraint, to allow the situation, where…
46
votes
5 answers

Rails 4.2 Server port forwarding on Vagrant does not work

I have a Vagrant VM with Rails installed with a sample app. The VM is configured to forward the port 3000 (of Rails Webrick server) to my host 3000 port. config.vm.network "forwarded_port", guest: 3000, host: 3000 Everything is configured as seen…
37
votes
3 answers

can't connect localhost:3000 ruby on rails in vagrant

I tried to connect localhost:3000 in windows rails server is running in vagrant(ubuntu 14.10) portforwarding is done when, I tried lynx 127.0.0.1:3000 in ubunutu, it works but, in windows, I can't connect localhost:3000, 127.0.0.1:3000 too just…
Henry
  • 1,227
  • 1
  • 9
  • 13
34
votes
6 answers

El Capitan upgrade: Library not loaded: /usr/local/lib/libmysqlclient.18.dylib

Error: /Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.3.20/lib/mysql2.rb:31:in `require':…
Askar
  • 5,282
  • 6
  • 49
  • 84
24
votes
1 answer

How can I get ActiveJob to enqueue jobs in Sidekiq on Heroku when called from the app (not the console)?

I'm running Rails 4.2 on Heroku (cedar), Ruby 2.1.6 I've got Sidekiq running locally on Redis with Foreman, and in my app I call Rails' new ActiveJob deliver_later methods like this, inside application_helper.rb: assigning_user =…
Jason Preston
  • 1,313
  • 1
  • 10
  • 12
23
votes
1 answer

Setting a default queue for ActionMailer deliver_later?

You can specify which queue to use when calling deliver_later in an ActionMailer by adding :queue as optional argument, e.g.: Notifier.welcome(User.first.id).deliver_later(queue: "low") Is there a way to do this in a general way, for all…
21
votes
1 answer

undefined method `cache' for nil:NilClass after upgrading to rails 4.2.5.1

While upgrading from rails 4.2.5 to the recently released 4.2.5.1, I have encountered this error. This error exists only for specs with a before_filter that render an invalid status, such as render file: "public/422", status: :unauthorized. I get…
Austin
  • 1,042
  • 1
  • 8
  • 26
21
votes
2 answers

Rails: Share enum declaration values between models

I'm applying enum on the following attribute: transparency The same attribute (with enum) is used in two different models: Category and Post Is it possible to share the enum values between models, to avoid code duplication: enum transparency:…
Fellow Stranger
  • 25,431
  • 22
  • 134
  • 188
18
votes
2 answers

devise and rspec-rails - How to sign-in user in Request type specs (specs tagged with type: :request)?

Environment Rails 4.2.0 ruby-2.2.1 [ x86_64 ] devise 3.4.1 rspec-core 3.2.2 rspec-rails 3.2.1 In my /spec/rails_helper.rb I have included Devise helpers for spec files tagged with type: :controller and type:…
Jignesh Gohel
  • 5,425
  • 4
  • 46
  • 82
15
votes
1 answer

Why is there a wrong number of arguments error when using redirect_to in Rails 4.2?

In the Rails 4.1.1 version of an app, I have the following create method in articles_controller: def create @article = Article.new(article_params) authorize @article if @article.save flash[:notice] = "Successfully created article." …
Chris Alley
  • 2,865
  • 2
  • 19
  • 30
14
votes
3 answers

Disable strong parameters for a specific action

I have a serious problem with strong parameters. Its working pretty well in my about 200 actions but in one it doesn't because I'm working very dynamic with the parameters there and I also cant change it because of the applications design. So I want…
davidb
  • 8,578
  • 4
  • 33
  • 69
13
votes
3 answers

How do I properly migrate from has_secure_password to encrypted_password (as both use password_digest) without losing old passwords?

Migrating from has_secure_password to devise causes the following error in the console when interacting with user objects: .rvm/gems/ruby-2.4.1/gems/devise-4.4.0/lib/devise/models/database_authenticatable.rb:166:in `password_digest' I understand…
Ayrad
  • 3,766
  • 7
  • 38
  • 81
1
2 3
47 48