Error editing user register with nested_form

Asked

Viewed 68 times

1

I’m having a problem with an app I did here on the job. I use nested_form together with Devise for a student registration, that is, when I register a student, I already add a user to it in the system, who can have access to grades among other things. However, when I edit the registration, it asks me to add the password again.I tried to create the custom controllers, but I was unsuccessful. So I’ll send you the links to some files so a charitable soul can help me .

User Model
https://gist.github.com/luizpicolo/e5d3dbb533c0be1518b0

Student model
https://gist.github.com/luizpicolo/96d9f58c3ac2824ce3ef

Student Controller
https://gist.github.com/luizpicolo/30d0e9578848b2c12315

  • http://meta.pt.stackoverflow.com/a/851/101

1 answer

0

as I recall, Devise asks to confirm the password whenever the user is changed.

The Vise wiki has a section talking about this. (https://github.com/plataformatec/devise/wiki/How-To%3a-Allow-users-to-Edit-their-Account-without-providing-a-password)

But as you are dealing with a nested Resource, my suggestion would be a hack within the user template, in which you would over-write the User update to call the update_without_password method. Then I’d be like this:

class User < ActiveRecord::Base
  def update(params, *options)
    update_without_password(params, *options)
  end
end

But remember that I’m not sure it works, and remember that this will ABOUT-WRITE update method in all cases (although I believe you could do it just by saving by Student with a little metaprogramming)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.