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 trialAbhay Sharma
8,287 PointsCreating Authentication Ruby - Adding field names to user.rb file
I have followed through the tutorials once and it was all fine. Just to practice I started doing it on my own and after the step when we add First Name, Last Name and Profile Name to our
app/views/devise/registrations/new.html.erb file
we have to add the same fields in app/models/user.rb but the file it have created this time is different from the previous one it, all it contains is
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
end
if I manually add
attr_accessible :email, :password, :password_confirmation, :remember_me,
:first_name, :last_name, :profile_name
at the end it giver me error
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.
This is my first interaction with ruby , so don't really know the error messages yet.
1 Answer
Obed Lorisson
Front End Web Development Techdegree Student 6,151 Pointsi think this is related to the new strong parameters from rails 4 , i had this issue with one of my apps , i fix it by follow the devise fix for rails on the documentation on rails 4, if you're using rails 3.2.or above , there's a gem that you suppose to add "protected attributes that you must add in order for it to function properly . The reason of that rails 4 move this feature from the model to the controller and instead of doing with attr_accessible they have a method like that in the controller : example. def strong_parameters params.require(:user).permit(:email, :first_name, :last_name) end. you can find more info in devise documentation and the strong_parameters in Github