Questions tagged [ruby-on-rails-4]

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

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

See Ruby on Rails 4.0 Release Notes for more information.

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

Resources

Related tags

36770 questions
54
votes
11 answers

Redis raises "NOAUTH Authentication required" error but there is no password setting

I got error NOAUTH Authentication required when I connect to Redis server via command: redis-cli and run ping to check if Redis is working. I found answer for NOAUTH Authentication required error which describes that this error only happens when…
Thanh
  • 8,219
  • 5
  • 33
  • 56
54
votes
3 answers

Running a spec in RubyMine results in "cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)"

OS: Arch Linux, Rails version: 4, RubyMine: 6.3 When I run a spec from Tools - Run Rake Task - spec I always get this error: /home/chylli/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1024:in `require': cannot…
chylli
  • 561
  • 1
  • 4
  • 7
54
votes
3 answers

Rails 4 find or create by method doesn't work

I have a one to many association between jobs and companies and it works fine. In the job form view I have text_field for the company name with an autocomplete feature. The autocomplete works fine but the find_or_create_by don't create a new company…
Loenvpy
  • 899
  • 1
  • 10
  • 30
54
votes
4 answers

Possible to alias a belongs_to association in Rails?

I have a model with a belongs_to association: class Car < ActiveRecord::Base belongs_to :vendor end So I can call car.vendor. But I also want to call car.company! So, I have the following: class Car < ActiveRecord::Base belongs_to :vendor def…
at.
  • 50,922
  • 104
  • 292
  • 461
54
votes
4 answers

How to query all records instead of .all() in Rails 4?

Now that ActiveRecord::Relation#all is deprecated in Rails 4, how do I iterate over all records? Previously: Foo.all.each do |foo| # whatever end I can approximate it now like this, but it feels dirty: Foo.where(true).each do |foo| #…
53
votes
5 answers

Rails 4 + Devise: Password Reset is always giving a "Token is invalid" error on the production server, but works fine locally.

I have a Rails 4 application set up to use Devise, and I'm running a problem with password resets. I have the mailer set up, and the password reset email sends fine. The link provided has the correct reset_password_token assigned to it, which I…
justindao
  • 2,273
  • 4
  • 18
  • 34
52
votes
6 answers

pluralize without count number in rails 4

I am building a blog app. I'd like to be able to pluralize the word "article" if more than one "post" is "published." Like so: Available Articles or Available Article This is what I have.... Available <%= pluralize @posts.published, "Article"…
NothingToSeeHere
  • 2,253
  • 5
  • 25
  • 57
52
votes
2 answers

Nginx cannot find unix socket file with Unicorn (no such file or directory)

I am deploying a Rails 4 app to a Fedora 19 x64 server using Nginx and Unicorn. The problem is that I get an error when visiting the address: "We're sorry, but something went wrong." My Nginx error log (/var/log/nginx/error.log) shows: 2014/03/08…
jamsesso
  • 1,848
  • 2
  • 17
  • 20
51
votes
6 answers

Uncaught ReferenceError: ReactDOM is not defined

So i have Rails applications, i installed react-rails gem, set it up and try to run test application. Freshly installed, when i tryed to run hello world program, this error hapened: Uncaught ReferenceError: ReactDOM is not defined This is my…
IvRRimUm
  • 1,724
  • 3
  • 21
  • 40
51
votes
5 answers

Rails 4, how to correctly configure smtp settings (gmail)

I am trying to create a contact form in Rails 4. I did some digging around here and was able to get most of the stuff to work. (followed @sethfri's work here Contact Form Mailer in Rails 4) Right now I am able to fill out my form box and hit send.…
ResrieC
  • 583
  • 1
  • 5
  • 6
51
votes
2 answers

Removing default value from Rails Migration

I found several similar questions about editing a migration but couldn't figure this one out. I did a rails migration, then opened the migration file and added a default value option to the field. Then ran rake db:migrate. The default value…
Moosa
  • 3,126
  • 5
  • 25
  • 45
51
votes
4 answers

Rails 4: Remove not null constraint from table column with migration?

Given the following schema.rb: create_table "people", force: true do |t| t.string "name", null: false t.integer "age" t.integer "height" t.string "email" t.boolean "married", default: false t.text "bio" …
gabethegrape
  • 681
  • 1
  • 6
  • 11
51
votes
6 answers

ArgumentError: A copy of ApplicationController has been removed from the module tree but is still active

I am using ActiveAdmin (with customized gemset for Rails 4) with Rails 4.0.0.rc2. Application also has custom-built authorization code based on railscasts #385 and #386. When I change something in a ActiveAdmin resource file and try to refresh the…
Subhash
  • 3,121
  • 1
  • 19
  • 25
50
votes
3 answers

How to create a migration to remove an index only if it exists, rather than throwing an exception if it doesn't?

Right now, the current migration might fail, if the books table doesn't have created_at or updated_at fields: class AddTimestampIndexes < ActiveRecord::Migration def up remove_index :books, :created_at remove_index :books, :updated_at …
TheFooProgrammer
  • 2,439
  • 5
  • 28
  • 43
50
votes
4 answers

Modify ruby hash in place( rails strong params)

This may be more a ruby question then rails question but I'm pretty sure I was able to do this in a vanilla ruby application. I have strong params defined. def trip_params params.require(:trip).permit(:name, :date) end Now I get those params in a…
Drew H
  • 4,699
  • 9
  • 57
  • 90