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 trialSuleiman Leadbitter
15,805 PointsGenerating 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
Suleiman Leadbitter
15,805 PointsI'm pretty sure the problem is in attr_accessible
although I'm not sure why :(
Richard Crawford-Wilson
6,094 PointsWhat errors do you have? What version of Rails are you using (type rails -v in your console)
Suleiman Leadbitter
15,805 PointsThanks 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
=> Run
rails 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:in
attr_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:in
block 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:in
load_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:in
load_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:in
const_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:in
each'
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:in
constantize'
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:in
constantize'
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:in
to'
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:in
routes'
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:in
initialize'
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:in
add_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:in
each'
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:in
block 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:in
eval_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:in
block 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:in
load'
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:in
each'
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:in
reload!'
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:in
call'
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:in
updater'
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:in
block 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:in
run'
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:in
block 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:in
each_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:in
each'
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:in
tsort_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:in
initialize!'
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:in
block 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:in
require'
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:in
instance_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:in
new'
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:in
eval'
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:in
parse_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:in
app'
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:in
wrapped_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:in
block 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
Treehouse Guest TeacherHey 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.
Suleiman Leadbitter
15,805 PointsCool. Thanks Jason Seifer and apologies for being a pest. This is all new to me :P
Suleiman Leadbitter
15,805 PointsOk 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 :(
Suleiman Leadbitter
15,805 PointsOk 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:in
eval'
/Users/Sulcalibur/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in <main>'
(See full trace by running task with --trace)
Richard Crawford-Wilson
6,094 PointsYea, 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.
Suleiman Leadbitter
15,805 PointsRichard 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 :/
Richard Crawford-Wilson
6,094 PointsAs 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.
unostella
1,155 PointsIf 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.
Matt Clarkson
4,801 PointsI added "gem 'protected_attributes'" to my Gemfile ... works ok at the moment.
Richard Crawford-Wilson
6,094 PointsThis might work for now but you'll run into other issues down the line