Skip to content

Instantly share code, notes, and snippets.

@mytrile
Created December 4, 2008 11:47
Show Gist options
  • Select an option

  • Save mytrile/31917 to your computer and use it in GitHub Desktop.

Select an option

Save mytrile/31917 to your computer and use it in GitHub Desktop.
This is the generated form.
<form method="post" action="/users">
<label for="user_login">Login</label>
<input type="text" class="text" value="" name="user[login]" id="user_login">
<label for="user_password">Password</label>
<input type="text" class="text" value="" name="user[password]" id="user_password"/>
<label for="user_password_confirmation">Confirm password</label>
<input type="text" class="text" value="" name="user[password_confirmation]" id="user_password_confirmation"/>
<input type="submit" value="Create" name="submit"/>
</form>
<%= form_for(@user, :action => resource(:users)) do %>
<%= text_field :login, :label => "Login" %>
<%= text_field :password, :label => "Password" %>
<%= text_field :password_confirmation, :label => "Confirm password" %>
<%= submit "Create" %>
<% end =%>
def new
only_provides :html
@user = User.new
display @user
end
def create(user)
@user = User.new(user)
if @user.save
redirect resource(@user), :message => {:notice => "User was successfully created"}
else
message[:error] = "User failed to be created"
render :new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment