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

Generating the Devise Views

Having problems with the Rails Server not starting up. This is my user.rb file where the problems are:

class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :profile_name

# attr_accessible :title, :body
end

Originally it never had the lines:

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me

  # attr_accessible :title, :body

Which were on the video, so I added them in also.Not sure if I was meant to do that :/

Help! cc Jason Seifer

6 Answers

I'm pretty sure the problem is in attr_accessible although I'm not sure why :(

What errors do you have? What version of Rails are you using (type rails -v in your console)

Thanks for the reply Richard Crawford-Wilson

  • Rails 4.0.0
  • ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]

Error message is a meaty one, you can see the server starts then a second later exits:

Sulcalibur@Ultra-Magnus:~/Documents/Work/Education/Treebook$ rails server => Booting WEBrick => Rails 4.0.0 application starting in development on http://0.0.0.0:3000 => Runrails server -hfor more startup options => Ctrl-C to shutdown server Exiting /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activemodel-4.0.0/lib/active_model/deprecated_mass_assignment_security.rb:17:inattr_accessible': attr_accessible is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add protected_attributes to your Gemfile to use old one. (RuntimeError) from /Users/Sulcalibur/Documents/Work/Education/Treebook/app/models/user.rb:9:in <class:User>' from /Users/Sulcalibur/Documents/Work/Education/Treebook/app/models/user.rb:1:in<top (required)>' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in load' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:inblock in load_file' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in new_constants_in' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:inload_file' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:in require_or_load' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:inload_missing_constant' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in const_missing' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:inconst_get' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:in block in constantize' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:ineach' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:in inject' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:inconstantize' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:534:in get' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:565:inconstantize' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise.rb:274:in get' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise/mapping.rb:77:into' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise/mapping.rb:72:in modules' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise/mapping.rb:89:inroutes' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise/mapping.rb:156:in default_used_route' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise/mapping.rb:66:ininitialize' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise.rb:308:in new' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise.rb:308:inadd_mapping' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise/rails/routes.rb:208:in block in devise_for' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise/rails/routes.rb:207:ineach' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/devise-3.0.0/lib/devise/rails/routes.rb:207:in devise_for' from /Users/Sulcalibur/Documents/Work/Education/Treebook/config/routes.rb:2:inblock in <top (required)>' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:in instance_exec' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:ineval_block' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:294:in draw' from /Users/Sulcalibur/Documents/Work/Education/Treebook/config/routes.rb:1:in<top (required)>' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in load' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:inblock in load' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in load_dependency' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:inload' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in block in load_paths' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:ineach' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in load_paths' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:16:inreload!' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:26:in block in updater' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/file_update_checker.rb:75:incall' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/file_update_checker.rb:75:in execute' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:27:inupdater' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in execute_if_updated' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:inblock in <module:Finisher>' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/initializable.rb:30:in instance_exec' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/initializable.rb:30:inrun' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/initializable.rb:55:in block in run_initializers' from /Users/Sulcalibur/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/tsort.rb:150:inblock in tsort_each' from /Users/Sulcalibur/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/tsort.rb:183:in block (2 levels) in each_strongly_connected_component' from /Users/Sulcalibur/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/tsort.rb:219:ineach_strongly_connected_component_from' from /Users/Sulcalibur/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/tsort.rb:182:in block in each_strongly_connected_component' from /Users/Sulcalibur/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/tsort.rb:180:ineach' from /Users/Sulcalibur/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/tsort.rb:180:in each_strongly_connected_component' from /Users/Sulcalibur/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/tsort.rb:148:intsort_each' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/initializable.rb:54:in run_initializers' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/application.rb:215:ininitialize!' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in method_missing' from /Users/Sulcalibur/Documents/Work/Education/Treebook/config/environment.rb:5:in<top (required)>' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in require' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:inblock in require' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in load_dependency' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:inrequire' from /Users/Sulcalibur/Documents/Work/Education/Treebook/config.ru:3:in block in <main>' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:55:ininstance_eval' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:55:in initialize' from /Users/Sulcalibur/Documents/Work/Education/Treebook/config.ru:innew' from /Users/Sulcalibur/Documents/Work/Education/Treebook/config.ru:in <main>' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:49:ineval' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:49:in new_from_string' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:40:inparse_file' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:277:in build_app_and_options_from_config' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:199:inapp' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/commands/server.rb:48:in app' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:314:inwrapped_app' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/commands/server.rb:75:in start' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/commands.rb:78:inblock in <top (required)>' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/commands.rb:73:in tap' from /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/commands.rb:73:in<top (required)>' from bin/rails:4:in require' from bin/rails:4:in<main>' `

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Suleiman Leadbitter we use Rails 3.2.13 in the videos. Any chance you can try again using Rails 3.2? There's a ton of differences between 3.2 and 4 that will cause problems when following along with the videos.

Cool. Thanks Jason Seifer and apologies for being a pest. This is all new to me :P

Ok I rolled back to earlier versions and now I'm getting the same text as the rails --help text as if there isn't a Ruby on Rails project i that directory. I have checked a few times and I am in the right directory :/ I changed the dependencies too so they are the right version and I also ran bundle which set it up,

And can't start the rails server at all now :(

Ok rather than flooding this thread with loads and loads of code I've added it to this Gist - I started a new project and rails server wouldn't start there either. So the above Gist is the error that shows up when I start the project in Anvil if this helps.

I was even thinking of ditching the project so far and starting again but the rails server doesn't start in anything so… bummer :/

I tried rake db:migrate also and just got this:

rake aborted! No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb) /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:ineval' /Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in <main>' (See full trace by running task with --trace)

Yea, I think something got messed up with your gem dependencies.

Try the following:

Remove the Gemfile, and Gemfile.lock files from your application directory.

Replace gemfile with this one here: https://github.com/Senjai/Treehouse/blob/master/treebook/Gemfile

do bundle install, and try again.

If this doesnt work, it may have been the fact you created a new project with rails 4, and are now trying to backport it to 3.2. You might have to pull down a copy of their code and pick up from there. But try the first approach first.

Richard Crawford-Wilson - Thank you. I followed everything you said but it still didn't work :( Is there anyway I can resolve the gem dependencies problems so they all work together nicely :/

As a matter of full disclosure, I know nothing about Rails 4.0. By the look of the error messages, it looks like it generated files that dont work with rails 3.2, and vica versa. The safest way would be:

Keep db/schema.rb. Copy my gemfile. Create a new project using rails 3.2.

Do the following in console:

bundle install rake db:create rake db:schema:load (this will apply all migrations from your last project, make sure you copy db/schema.rb from old project)

Then copy over the files from your old project one by one and see which ones give you trouble, or copy the ones from teamtreehouse's download directly.

If I can say something, it's a good idea to update your tutorials to use latest Ruby 2.0.0 and Rails 4.0.0. As a programmer who just started learning Ruby, courses based on latest version are obviously more 'privileged' and there is already few of them out there. However after comparing em all, to my own surprise, I decided to go with... your site! I probably like the look & feel or something and despite this 3.2 version, I just follow your lessons and things that don't work in Rails 4, I just look up on Google :)

So... keep up the good work and update your gems if you want to have more happy customers like me and stay ahead of competition.

I added "gem 'protected_attributes'" to my Gemfile ... works ok at the moment.

This might work for now but you'll run into other issues down the line