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
Ian Warner
5,563 PointsBuild a basic ruby application project "treebook": syntax error :first_name, :last_name, :profile_name
After adding the following code:
# Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me (added this line) --> :first_name, :last_name, :profile_name
to the "user.rb" file and saved it and refreshed the page "http://0.0.0.0:3000/users" I get the following errors:
SyntaxError in Devise::RegistrationsController#create
syntax error, unexpected ',', expecting keyword_end
:first_name, :last_name, :profile_name
If anyone has figured this out I'd really appreciate your help.
Thanks!
Xander Miller
9,072 PointsYou are using Rails 4.0 and the tutorial is for Rails 3. There is no more attr_accessible in Rails 4. Victor and I discussed it here. https://teamtreehouse.com/forum/devise-gem-behavior-changed-in-rails-40
Ian Warner
5,563 PointsHey Victor & Alexander,
Here is my user.rb file:
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
I also checked what version of rails I'm running and it's version 3.2.12. If you could help me out so I can move on with my project I'd really appreciate it. I can't really do much more until I get this issue resolved.
Thanks, Ian
Sandra Weber
1,531 PointsHi Ian,
You are missing a comma after ":remember_me". The line should look like this:
attr_accessible :email, :password, :password_confirmation, :remember_me,
Ian Warner
5,563 PointsHey Sandra, Thanks for helping me out. That fixed everything! I really appreciate it! :)
Ian
Xander Miller
9,072 PointsSorry for my reflexive reaction Ian I got the similar error in the same place, assumed the same cause.
Remi Williams
4,004 PointsGlad you posted it Alexander. I had the same problem running Rails 4.0 I noticed my user.rb file was missing half the content shown in the video. I decided to skip that section and everything runs okay...so far, will report if anything goes wrong down the road.
Xander Miller
9,072 PointsA few lessons down your going to run into trouble once you start setting up relationships between models, unless you update the controller.
Remi Williams
4,004 PointsOk. Problems are now occurring. How do you update the controller?
Victor Miclovich
9,108 PointsHi Remi, which controller would you like to update? A users' controller?
Victor Miclovich
9,108 PointsHi Remi, I'm slowly working on a Rails4 compatible version of Treebook; hopefully, you can follow along, I might take a little step and put in some more documentation on the codebase.
Remi Williams
4,004 PointsI'm not really sure what to update, I'm going off Alexander's reply. The problem begins when you can't update attr accessible in user.rb in "part 3" because it's no longer used in rails 4.0. When you get to "part 4 Customizing forms" and try to change things around to use full_name and check the browser, you see that everything is screwed!
I'll let you know if looking at your repo helps...thanks for posting it.
1 Answer
Remi Williams
4,004 PointsIf you find you're using Rails 4.0, you can change to the earlier version used in this tutorial with
$ rails 3.2.6 new treebook
You will have to start from scratch.
Victor Miclovich
9,108 PointsVictor Miclovich
9,108 PointsCan you paste your
user.rbfile? Chances are you've left out theendkeyword at the end of the file.