Rails/Devise - How can I split the registrations/edit view in 2 parts (Account info, Password info)

281 views
Skip to first unread message

benoitr

unread,
Oct 20, 2010, 11:28:40 AM10/20/10
to Devise
0 down vote favorite


Hi,

Using Devise, I wonder what is the best way to split the devise/
registrations/edit view in order to get:

1) A view with "Account info" with fields like: username and email and
2) A view with "password info" with fields like current, new, confirm
password

I figured out to leave only the passwords fields (current, new,
confirm) in the devise/registrations/edit view and create a new view
for Account info. However, if I proceed like this, should I have to
include my new view in the devise views folder?

I would be pleased to know your thought!

Thank you!

phil

unread,
Oct 20, 2010, 5:55:09 PM10/20/10
to Devise
Not sure I entirely understand what you mean. When you say 'view' do
you mean a completely different screen for the user? If so you might
want to look at my other posting about my blog entry on a pseudo
multistage signup.

benoitr

unread,
Oct 20, 2010, 7:13:05 PM10/20/10
to Devise
Hi Phil, Thanks for your answer. It could help me.
What I want is to split the edit registrations view in 2 new views,
for example:

1.) views/account/index.html.erb (with the following route: settings/
account)

<%= form_for(resource, :as => resource_name, :url =>
registration_path(resource_name), :html => { :method => :put }) do |f|
%>
<%= devise_error_messages! %>

<%= f.label :username %>
<%= f.text_field :username %>

<%= f.label :email %>
<%= f.text_field :email %>

<%= f.submit "Save" %>
<% end %

and
2.) views/password/index.html.erb (with the following route: settings/
password)

<%= form_for(resource, :as => resource_name, :url =>
registration_path(resource_name), :html => { :method => :put }) do |f|
%>
<%= devise_error_messages! %>

<%= f.label :password, "New Password" %>
<%= f.password_field :password %>

<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>

<%= f.label :current_password %>
<%= f.password_field :current_password %>

<%= f.submit "Save" %>
<% end %>

and my question is, in order to accomplish this: did I have to
overwrite the registration controller or there is a better way to get
this result?
Thanks for any suggestion!

AppleII717

unread,
Oct 25, 2010, 6:22:47 PM10/25/10
to Devise
Since I've been hanging out here, waiting to see if anyone responds to
my post, I throw up an approach.

I've tried several approaches of splitting out account information. A
polymorphic link in users to different loginable_type models, etc.

My most resent approach turned out to be real easy.

I created a Member model (or Account, or whatever) that inherited
user.

class Member < User
end

I added account fields to the user model (name, address, etc)

Then created a Members controller and views (really scaffold, but
without new and create)

To edit the account information, its just edit_members_path.

I just left the Devise views the same and used the Members views for
the account information. Of course you can do whatever meets you
needs.

Simplest way I found yet. A lot simpler than trying to put account
information in a polymorphic relation - but that also worked.

Steve

benoitr

unread,
Oct 25, 2010, 6:35:41 PM10/25/10
to Devise
Thanks! I'll try this!

Anshu Pitlia

unread,
Dec 11, 2014, 12:41:22 AM12/11/14
to plataforma...@googlegroups.com, benoit...@gmail.com
how to achieve this using modal?

The electronic communication and its contents are confidential, non-public and privileged information and are intended solely for the addressee. If you have received this electronic communication in error, please advise the sender immediately, and delete it from your system (if permitted by law). Access to this communication by anyone else is unauthorized. Any printing, copying, distribution or any other usage of this communication beyond the original addressee is not permissible, and may be unlawful.
Reply all
Reply to author
Forward
0 new messages