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

Ruby Build a Simple Ruby on Rails Application Customizing Forms Creating Relationships

Deprecated attr_accessible

I have a later version of Rails installed, and it has attr_accessible deprecated. I've been searching around, and all the advice indicates that you should white list the attributes in the controller: class UserController < ActionController

def create User.create(user_params) end

private def user_params params.require(:user).permit(:first_name, :last_name, :profile_name) end end

But there is no user_controller.rb in this project. I tried creating one of my own, but it doesn't work, and I'm not sure this is correct.

Any advice?

2 Answers

I didn't, just created the file. But I was looking at some other answers, which say to use this in the application controller:

before_filter :configure_permitted_parameters, if: :devise_controller?

protected # Devise using strong parameters . (lazy way!) def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name,:last_name,:profile_name,:email, :password) } devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name,:last_name,:profile_name,:email, :password) } end

And this worked.

Thanks for your response!

Stone Preston
Stone Preston
42,016 Points

In rails 4 you need to use strong parameters, which are enforced at the controller level as opposed to the model level where attr_accessible was. What command did you run to create your own controller?