0

I have used Devise for authentication.

Went ahead and updated my Users database to include a bio column. Added this and ran the migration so I can see it is there.

Now I want Users to be able to add a bio once they are logged in. Did some research and I see attr_accessible is no more in rails 4 and I should use strong parameters. Also checked out the Devise documentation but couldn't quite find what I am after.

I see they are added to the controller but as I have used Devise I don't have access to the UsersController

How can I add the ability for Users to update the bio field so it saves in the database?

PatGW
  • 369
  • 6
  • 19
  • 1
    everything is in the Devise read me. https://github.com/plataformatec/devise#configuring-views and https://github.com/plataformatec/devise#strong-parameters – Mike Szyndel Aug 15 '14 at 22:22
  • Thanks Michael I missed the account_update part which I should have seen and that explained what I needed. – PatGW Aug 15 '14 at 22:42

1 Answers1

1

You should add a before_filter in your ApplicationController to do that. Devise docs contains a section explaining this. I took the code below from there:

class ApplicationController < ActionController::Base
  before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :username
  end
end

In the example, the attribute :username is allowed to be parsed in the sign_up page.

Victor
  • 638
  • 4
  • 6
  • Thanks Victor I missed the account_update part which I should have seen and that explained what I needed. – PatGW Aug 15 '14 at 22:41