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 trialCJ Jean
519 PointsHow do I make custom fields save with a devise created user table?
Hi I am adding new columns to my devise user generated table in rails. Now the users/new and users/edit have the new fields. However in the rails console, the new fields are nil. I still have a blank model which may be the problem The other issue may be in application controller . I have followed the instructions from http://www.peoplecancode.com/tutorials/adding-custom-fields-to-devise regarding adding code to the application controller, however, I am getting this error in the server: undefined method `before_filter' for ApplicationController:Class Did you mean? before_action
Sandra Hogan
8,657 Pointsbefore_action is just a new syntax for before_filter. Also I agree with Brian Gilbank about making sure you have whitelisted your devise fields.
1 Answer
CJ Jean
519 PointsOH Thank you! I will try it asap! can tell this will be helpful knowledge to know anyway!
Brian Gilbank
9,586 PointsBrian Gilbank
9,586 PointsWithout looking at your link, you probably need to white list your new devise fields.
This is what I do:
Open your application controller and add: include DeviseWhitelist
Now go to controller/concerns and add a new file called devise_whitelist.rb
Above you can see my custom devise fields: :first_name, :last_name, :about, :type. You can just replace it with your fields, but you need to do it for both sign up and account update.