Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Error when running rails console

I'm having this problem when I run the rails console command, I'm using nitrous because Rails Installer hasn't yet updated to OSX Mavericks. Here's the error:

        /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activemodel-4.0.1/lib/active_model/deprecated_mass_assignment_security.rb:14:in `attr_accessible': `attr_ac                                                                                                                                                                                                                                                            
tracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add `protected_attributes` to your Gemfil                                                                                                                                                                                                                                                            
e. (RuntimeError)                                                                                                                                                                                                                                                                                                                                                                                                  
        from /home/action/workspace/treebook/app/models/user.rb:6:in `<class:User>'                                                                                                                                                                                                                                                                                                                                
        from /home/action/workspace/treebook/app/models/user.rb:1:in `<top (required)>'                                                                                                                                                                                                                                                                                                                            
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:424:in `load'                                                                                                                                                                                                                                                                                      
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:424:in `block in load_file'                                                                                                                                                                                                                                                                        
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:616:in `new_constants_in'                                                                                                                                                                                                                                                                          
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:423:in `load_file'                                                                                                                                                                                                                                                                                 
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:324:in `require_or_load'                                                                                                                                                                                                                                                                           
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:463:in `load_missing_constant'                                                                                                                                                                                                                                                                     
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:184:in `const_missing'                                                                                                                                                                                                                                                                             
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:226:in `const_get'                                                                                                                                                                                                                                                                            
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:226:in `block in constantize'                                                                                                                                                                                                                                                                 
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:224:in `each'                                                                                                                                                                                                                                                                                 
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:224:in `inject'                                                                                                                                                                                                                                                                               
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/inflector/methods.rb:224:in `constantize'                                                                                                                                                                                                                                                                          
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:535:in `get'                                                                                                                                                                                                                                                                                       
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:566:in `constantize'                                                                                                                                                                                                                                                                               
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise.rb:297:in `get'                                                                                                                                                                                                                                                                                                                   
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:77:in `to'                                                                                                                                                                                                                                                                                                             
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:72:in `modules'                                                                                                                                                                                                                                                                                                        
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:89:in `routes'                                                                                                                                                                                                                                                                                                         
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:156:in `default_used_route'                                                                                                                                                                                                                                                                                            
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/mapping.rb:66:in `initialize'                                                                                                                                                                                                                                                                                                     
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise.rb:331:in `new'                                                                                                                                                                                                                                                                                                                   
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise.rb:331:in `add_mapping'                                                                                                                                                                                                                                                                                                           
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/rails/routes.rb:218:in `block in devise_for'                                                                                                                                                                                                                                                                                      
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/rails/routes.rb:217:in `each'                                                                                                                                                                                                                                                                                                     
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/rails/routes.rb:217:in `devise_for'                                                                                                                                                                                                                                                                                               
        from /home/action/workspace/treebook/config/routes.rb:2:in `block in <top (required)>'                                                                                                                                                                                                                                                                                                                     
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'                                                                                                                                                                                                                                                                          
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'                                                                                                                                                                                                                                                                             
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/routing/route_set.rb:319:in `draw'                                                                                                                                                                                                                                                                                   
        from /home/action/workspace/treebook/config/routes.rb:1:in `<top (required)>'                                                                                                                                                                                                                                                                                                                              
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in `load'                                                                                                                                                                                                                                                                                      
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in `block in load'                                                                                                                                                                                                                                                                             
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'                                                                                                                                                                                                                                                                           
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in `load'                                                                                                                                                                                                                                                                                      
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'                                                                                                                                                                                                                                                                       
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:40:in `each'                                                                                                                                                                                                                                                                                      
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:40:in `load_paths'                                                                                                                                                                                                                                                                                
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:16:in `reload!'                                                                                                                                                                                                                                                                                   
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:26:in `block in updater'                                                                                                                                                                                                                                                                          
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/file_update_checker.rb:75:in `call'                                                                                                                                                                                                                                                                                
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/file_update_checker.rb:75:in `execute'                                                                                                                                                                                                                                                                             
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:27:in `updater'                                                                                                                                                                                                                                                                                   
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'                                                                                                                                                                                                                                                                         
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'                                                                                                                                                                                                                                                                       
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/initializable.rb:30:in `instance_exec'                                                                                                                                                                                                                                                                                           
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/initializable.rb:30:in `run'                                                                                                                                                                                                                                                                                                     
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'                                                                                                                                                                                                                                                                               
        from /home/action/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'                                                                                                                                                                                                                                                                                                         
        from /home/action/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'                                                                                                                                                                                                                                                                       
        from /home/action/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'                                                                                                                                                                                                                                                                                      
        from /home/action/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'                                                                                                                                                                                                                                                                                  
        from /home/action/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:180:in `each'                                                                                                                                                                                                                                                                                                                        
        from /home/action/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'                                                                                                                                                                                                                                                                                           
        from /home/action/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'                                                                                                                                                                                                                                                                                                                  
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/initializable.rb:54:in `run_initializers'                                                                                                                                                                                                                                                                                        
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application.rb:215:in `initialize!'                                                                                                                                                                                                                                                                                              
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/railtie/configurable.rb:30:in `method_missing'                                                                                                                                                                                                                                                                                   
        from /home/action/workspace/treebook/config/environment.rb:5:in `<top (required)>'                                                                                                                                                                                                                                                                                                                         
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'                                                                                                                                                                                                                                                                                   
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `block in require'                                                                                                                                                                                                                                                                          
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'                                                                                                                                                                                                                                                                           
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'                                                                                                                                                                                                                                                                                   
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/application.rb:189:in `require_environment!'                                                                                                                                                                                                                                                                                     
        from /home/action/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.1/lib/rails/commands.rb:61:in `<top (required)>'                                                                                                                                                                                                                                                                                             
        from bin/rails:4:in `require'                                                                                                                                                                                                                                                                                                                                                                              
        from bin/rails:4:in `<main>'                                             

3 Answers

One of your models (probably statuses) is using attr_accessible, which is no longer supported in Rails 4. Note that videos here are using Rails 3.2.12. So either study up on the changes between Rails 3.2 and Rails 4, or in your gem file, change to use Rails 3.2.12

gem 'rails', '3.2.12'

Okay thanks for the help!

For Rails 4 and Devise:

It's tricky for me as I'm a noob. It's a two part solution for the controller page: Works for me, FYI, I use a :profile_name here and you may not

class ApplicationController < ActionController::Base
    # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_filter :configure_permitted_parameters, if: :devise_controller?


protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit( :first_name, :last_name, :profile_name, :password_confirmation, :password, :email ) }
    devise_parameter_sanitizer.for(:sign_in) { |u| u.permit( :profile_name, :password, :email ) }
  end

end