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 trialDavid Curtis
11,301 PointsError message - please help
When trying to run rake db:migrate from the cmd prompt, I get the following error:
C:\Users\David\Documents\treebook>rake db:migrate
rake aborted!
NoMethodError: undefined method devise' for User (call 'User.connection' to est
ablish a connection):Class
C:/Users/David/Documents/treebook/app/models/user.rb:5:in
<class:User>'
C:/Users/David/Documents/treebook/app/models/user.rb:1:in <top (required)>'
C:/Users/David/Documents/treebook/config/routes.rb:2:in
block in <top (required
)>'
C:/Users/David/Documents/treebook/config/routes.rb:1:in <top (required)>'
C:131071:in
execute_if_updated'
C:/Users/David/Documents/treebook/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
4 Answers
Adam Sackfield
Courses Plus Student 19,663 PointsRight well you should ideally start over with Rails 3.2 and Ruby 1.9.3 as these are the versions used in the video and there have been numerous changes in Rails 4, for instance attr_accessible is no longer used and the preferred method of using strong params inside the controller.
But I highly suggest for your sanity (as I had similar issues) starting over with the correct versions, then do the todo list course on here with Rails 4 to get a feel of what has changed. You could fix this issue but you will run into others later down the line and it will hinder your learning or may even deter you from Rails too.
Also here is a great tutorial text based for rails 3.2 and rails 4 which will explain every detail and is a great complement to the videos on here. The link here just chose the version on the right. I would ideally read the whole thing before following along to get the knowledge inside your brain.
David Curtis
11,301 PointsHi Adam,
Thanks for trying to help. Here are the contents of user.rb:
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
FYI, I cannot restart the rails server no matter what I try. Thank you! I don't know if it's because I am running newer versions of ruby and rails or what (I am very new to both, btw). Ruby version is 2.0.0 and rails is 4.0.4.
David Curtis
11,301 PointsHi Adam. Thanks a lot for your quick replies.
So I guess I need to uninstall these versions of ruby and rails and then re-install the older versions, is that right? I don't mind starting over since it's still pretty early on. I'm not going to give up on either - I'm actually attending a RoR bootcamp starting next month, which is why I'm giving it a try here.
Is there an easy way to uninstall these? And I'm guessing I can't use the rubyinstaller since it has the updated versions.
Again, many thanks. :)
Maybe I missed it, but perhaps you can add to the first page of the course to only install the older versions so others won't have these issues, too.
Adam Sackfield
Courses Plus Student 19,663 PointsNo problem.
What system are you using Mac/Windows as I believe Mac has RVM (Ruby Version Manager) to choose a version to work with then you can just gem install the rails version you require. I am a novice in RoR really and it is my main area to concentrate on. That bootcamp sounds interesting where is that based? Maybe we could share our progress and guide each other through the minefield :)
David Curtis
11,301 PointsI'm on Windows 8.1 (which I really don't like, btw).
It is called Tech Talent South. It's fairly new and started in Atlanta, but coming to my town (Raleigh) next month. So far, all of their grads have found work in the field w/in one to two weeks. It's 8 weeks and about $5k, which is a deal in my book compared to what I've seen from other programs.
I am happy to stay in touch! Is there a way to send you my email address? Good luck to you and thanks again!
Adam Sackfield
Courses Plus Student 19,663 PointsI am on Windows 8.1 too and I hate it, wish I could afford a Mac but hey they are like twice as expensive for similar specs, but damn pretty lol.
That sounds like a steal, shame I am in the UK and we don't seem to have as many things like you guys do in the States for bootcamps and such.
Yeah defo stay in touch and exchange notes and stuff my email is Sacki2013@gmail.com
Good luck to you too and thanks :)
Adam Sackfield
Courses Plus Student 19,663 PointsAdam Sackfield
Courses Plus Student 19,663 PointsCould you past in the contents of the user.rb file please.