Created
December 3, 2010 15:59
-
-
Save jferris/727136 to your computer and use it in GitHub Desktop.
semiformal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UsersController < ApplicationController | |
| def edit | |
| assign_user_form | |
| end | |
| def update | |
| if assign_user_form.commit | |
| redirect_to @user, :flash => "User saved." | |
| else | |
| render 'new' | |
| end | |
| end | |
| private | |
| def assign_user_form | |
| @user = User.find(params[:id]) | |
| @user_form = form_for(@user) do |form| | |
| form.accept :email | |
| form.accept :password | |
| form.accept :password_confirmation | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- generate all fields/buttons --> | |
| <%= render_form @user_form %> | |
| <!-- choose fields --> | |
| <%= render_form @user_form do |form| -%> | |
| <%= form.fieldset do -%> | |
| <!-- custom field --> | |
| <%= form.field :email do |field| -%> | |
| <%= field.label %> | |
| <%= field.input %> | |
| <a href="#" id="check_email">Check availability</a> | |
| <% end -%> | |
| <%= form.field :password -%> | |
| <%= form.field :password_confirmation -%> | |
| <% end -%> | |
| <!-- default buttons --> | |
| <%= form.buttons -%> | |
| <!-- button with cancel --> | |
| <%= form.buttons :cancel => user_path(@user) %> | |
| <!-- custom buttons --> | |
| <%= form.buttons do -%> | |
| <%= form.commit_button 'Save User' %> | |
| <% end -%> | |
| <% end -%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment