I'm trying to split the users edit page (app/views/devise/registrations/edit.html.erb) into 2 pages for better UI, like:
/settings
/settings/profile
I'm fairly new to Rails, did Michael Hartl's tutorial and had read a few more I got my hands on, just building my first application, even if I have some experience with php
This is the view I try to split in 2, it is a view provided by the Devise gem (app/views/devise/registrations/edit.html.erb)
<h2>Login Details</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%# sensitive info %>
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
....
<%= f.label :current_password %> <i>(to confirm changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %>
<h2>Profile Details</h2>
<%# non-sensitive info %>
<%= f.label :name %><br />
<%= f.text_field :name %>
<%= f.submit "Update" %>
<% end %>
It uses a custom RegistrationsController (app/controllers/registrations_controller.rb)
class RegistrationsController < Devise::RegistrationsController
def update
....
end
end
Further more, this view is accessed via this route:
edit_user GET /users/:id/edit(.:format) users#edit
My main question is, how do I split this page into 2:
- /settings containing Login Details
- /settings/profile containing Profile details
and both to processed by the same controller, or the same action
Do I need to create a new controler/route/view, like:
- controller: SettingsProfile
- route: get 'settings/profile' => 'settings_profile#new'
- view: app/views/settings_profile/new.html.erb
If so how do I pass the view the "resource" information, or any information for the matter of fact:
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
Things are pretty fuzzy at this point, please bear with me on this one