Я нашел, что это самый простой способ разделить форму редактирования пользователя на edit & account
Изначально у меня было
:name,
:email,
:avatar,
:location,
:website,
:bio,
:password (all in one form)
МАРШРУТЫ (это обеспечивает маршрут:
account_user GET /users/:id/account(.:format) users # account)
resources :users do
member do
get :following, :followers, :account
end
end
USERS_CONTROLLER.RB
before_filter :signed_in_user, only: [:index, :edit, :update, :destroy, :following, :followers, :account]
before_filter :correct_user, only: [:edit, :update, :account]
def edit
@user = User.find(params[:id])
end
def account
@title = "Account"
@user = User.find(params[:id])
end
def update
if @user.update_attributes(params[:user])
flash[:success] = "Profile updated"
sign_in @user
redirect_to @user
elsif @title = "Account"
render 'account'
else
render 'edit'
end
end
(разделенные формы просмотра)
edit.html.erb
<%= form_for @user, :html => { :multipart => true } do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :avatar %><br />
<%= f.file_field :avatar %>
<%= f.label :location %>
<%= f.text_field :location %>
<%= f.label :website %>
<%= f.text_field :website %>
<%= f.label :bio %>
<%= f.text_area :bio, placeholder: "About yourself in 160 characters or less..." %>
<%= f.submit "Update Profile", class: "btn btn-medium btn-primary" %>
<% end %>
ACCOUNT.HTML.ERB
<%= form_for @user, :html => { :multipart => true } do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirm Password" %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Update Account", class: "btn btn-medium btn-primary" %>
<% end %>
SIDE NAV BAR ВНИЗ РЕДАКТИРОВАНИЯ И СЧЕТА, ТАК ЧТО ПОЛЬЗОВАТЕЛЬ ДОСТУПЕН ДЛЯ РЕДАКТИРОВАНИЯ И ФОРМЫ СЧЕТА
<ol class="nav nav-tabs nav-stacked">
<% @user ||= current_user %>
<li>
<a href="<%= edit_user_path(@user) %>">
Profile
<i class="icon-chevron-right"></i>
</a>
</li>
<li>
<a href="<%= account_user_path(@user) %>">
Account
<i class="icon-chevron-right"></i>
</a>
</li>
</ol>