Monday, July 8, 2013

Re: [Rails] Re: how to add name field to devise controller

On 8 July 2013 14:58, mike <mruch@kalanitech.com> wrote:
>
>
> On Monday, July 8, 2013 8:31:01 AM UTC-4, Colin Law wrote:
>>
>> On 8 July 2013 13:27, mack gille <li...@ruby-forum.com> wrote:
>> > Colin Law wrote in post #1114719:
>> >> On 8 July 2013 10:52, mack gille <li...@ruby-forum.com> wrote:
>> >>> hi all,
>> >>> how to add name field to devise controller.
>> >>
>> >> Have a look at [1], it may be helpful.
>> >>
>> >> [1]
>> >>
>> >
>> > https://www.google.co.uk/search?q=how+to+add+name+field+to+devise+controller&ie=UTF-8
>> >>
>> >> Colin
>> >
>> > i din't get any sources colin
>>
>> Did not [2] help? For me it was linked to by the second result in
>> google (the first was your question itself).
>>
>> Colin
>>
>> [2]
>> http://eureka.ykyuen.info/2011/03/03/rails-%E2%80%93-add-custom-fields-to-devise-user-model/
>
>
> There's one update to these links. These links tell you to add your
> attribute (in your case, :username) to attr_accessible in the model user.rb.
> Devise has be re-written since these links were written to use strong
> parameters. Instead of adding the attr_accessible line to your model, you
> need to create a custom controller which is a bit of work. Following the
> example of these links, to add the attribute :username to the model users,
> you would add the following users_controller.rb:
>
> class UsersController < Devise::RegistrationsController
>
> private
>
> def sign_up_params
> params.require(:user).permit(:username, :email, :password,
> :password_confirmation)
> end
>
> def account_update_params
> params.require(:user).permit(:username, :email, :password,
> :password_confirmation, :current_password)
> end
>
> end
>
> Note that the controller inherits from Devise::RegistrationsController, not
> ApplicationController.
>
> You will then need to change your routes in config/routes.rb by adding the
> following lines:
>
> devise_for :users, :controllers => { :registrations => "users" }
>
> devise_scope :user do
> resources :users
> end
>
> This is, obviously, considerable more work but will be necessary going
> forward with strong parameters.
>
> The other steps in the links provided still apply.

That is good to know, thanks Mike.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs%3DbnqWX4JYR152rc-XsHz4a4YLG14qrLbk2ru1WAkPCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate