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!
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
Simon White2,491 Points
Missing field data?
I'm a bit confused by this lesson....
Firstly, I don't receive any error message regarding protected attributes and when I insert the required attr_accessible line into the model I get a rails based error suggesting I shouldn't be setting accessible attributes that way anymore.
Also, I noticed that when browsing the database with the rails console the first_name, last_name and profile_name fields are blank (i.e. not recording data from the forms). Thought this may have something to do with the above, but then I noticed the teachers output in the console was also not recording any data for these fields.
Am I missing something?
Justin HornerTreehouse Guest Teacher
Rails 4 introduced strong parameters which changes the way this is done. Now you will set the attributes that are permitted from the controller instead of the model.
Here's an example from the documentation.
private # Using a private method to encapsulate the permissible parameters is # just a good pattern since you'll be able to reuse the same permit # list between create and update. Also, you can specialize this method # with per-user checking of permissible attributes. def person_params params.require(:person).permit(:name, :age) end
Since this course is quite old, you might want to consider going through Build a Todo List Application with Rails 4 if you haven't already. You'll probably encounter several difficulties while going through Build a Simple Ruby on Rails Application with a recent version of Rails.
Not impossible, of course, just not optimal if you're trying to learn Rails for the first time :)
I hope this helps.