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
197
votes
3 answers

What is `params.require(:person).permit(:name, :age)` doing in Rails 4?

All the examples of strong parameters in Rails 4 docs use params.require(:person).permit(:name, :age) Could someone please deconstruct and explain what is occurring with require and permit here?
Erik Trautman
  • 5,883
  • 2
  • 27
  • 35
188
votes
15 answers

How to solve error "Missing `secret_key_base` for 'production' environment" (Rails 4.1)

I created a Rails application, using Rails 4.1, from scratch and I am facing a strange problem that I am not able to solve. Every time I try to deploy my application on Heroku I get an error 500: Missing `secret_key_base` for 'production'…
Paolo Laurenti
  • 2,714
  • 2
  • 16
  • 18
161
votes
6 answers

A copy of xxx has been removed from the module tree but is still active

I'm pretty sure the error has nothing to do with the actual content of the TenantIdLoader module. Instead, it has something to do with ActiveSupport Dependencies. I can't seem to get past this error. From what I've read, it's because either…
kddeisz
  • 5,162
  • 3
  • 21
  • 44
157
votes
12 answers

Rails Observer Alternatives for 4.0

With Observers officially removed from Rails 4.0, I'm curious what other developers are using in their place. (Other than using the extracted gem.) While Observers were certainly abused and could easily become unwieldily at times, there were many…
kennyc
  • 5,490
  • 5
  • 34
  • 57
153
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:…
149
votes
18 answers

cannot load such file -- bundler/setup (LoadError)

I'm setting Rails 4 application with Ruby 2.0, but I'm getting "Web application could not be started" and get this trace: cannot load such file -- bundler/setup (LoadError) …
Mr_Nizzle
  • 6,644
  • 12
  • 55
  • 85
148
votes
6 answers

scopes with lambda and arguments in Rails 4 style?

I'm wondering how the following is done in Rails 4 or if I just use the Rails 3 approach for using a lambda that can pass an argument the same way with 4 as I do with 3. I'm pretty new to Rails 3 and trying to work through some samples running…
kaplan
  • 4,109
  • 6
  • 30
  • 35
146
votes
29 answers

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

Before anything, please note that I have found several similar questions on Stack Overflow and articles all over the web, but none of those helped me fix my issue: PG Error could not connect to server: Connection refused Is the server running on…
128
votes
6 answers

Nested attributes unpermitted parameters

I have a Bill object, which has many Due objects. The Due object also belongs to a Person. I want a form that can create the Bill and its children Dues all in one page. I am trying to create a form using nested attributes, similar to ones in this…
jcanipar
  • 1,442
  • 2
  • 11
  • 8
126
votes
6 answers

How get integer value from a enum in Rails?

I have a enum in my Model that corresponds to column in the database. The enum looks like: enum sale_info: { plan_1: 1, plan_2: 2, plan_3: 3, plan_4: 4, plan_5: 5 } How can I get the integer value? I've tried Model.sale_info.to_i But this only…
Cleyton
  • 2,338
  • 6
  • 23
  • 39
124
votes
18 answers

Rails 4: assets not loading in production

I'm trying to put my app into production and image and css asset paths aren't working. Here's what I'm currently doing: Image assets live in /app/assets/images/image.jpg Stylesheets live in /app/assets/stylesheets/style.css In my layout, I…
emersonthis
  • 32,822
  • 59
  • 210
  • 375
120
votes
3 answers

There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)

Why am i getting this error? shibly@mybox:~/blog$ rails server /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'.…
cola
  • 12,198
  • 36
  • 105
  • 165
120
votes
9 answers

Saving enum from select in Rails 4.1

I am using the enums in Rails 4.1 to keep track of colors of wine. Wine.rb class Wine < ActiveRecord::Base enum color: [:red, :white, :sparkling] end In my view, I generate a select so the user can select a wine with a certain color f.input…
Brian Weinreich
  • 7,692
  • 8
  • 35
  • 59
118
votes
8 answers

Disable ActiveRecord for Rails 4

I want to disable ActiveRecord in Rails 4. I did the following in config/application.rb require File.expand_path('../boot', __FILE__) # require 'rails/all' -- commented require "action_controller/railtie" require "action_mailer/railtie" #require…
Incerteza
  • 32,326
  • 47
  • 154
  • 261
114
votes
6 answers

fe_sendauth: no password supplied

database.yml: # SQLite version 3.x # gem install sqlite3 # # Ensure the SQLite 3 gem is defined in your Gemfile # gem 'sqlite3' development: adapter: postgresql encoding: utf8 database: sampleapp_dev #can be anything unique #host:…
7stud
  • 46,922
  • 14
  • 101
  • 127