Skip to content

Instantly share code, notes, and snippets.

@dasdennis
Forked from rbarazi/users_controller.rb
Created April 13, 2012 21:26
Show Gist options
  • Save dasdennis/2380279 to your computer and use it in GitHub Desktop.
Save dasdennis/2380279 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 7-2. Updated app/controllers/users_controller.rb
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to articles_path, :notice => 'User successfully added.'
else
render :action => 'new'
end
end
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
redirect_to articles_path, :notice => 'Updated user information successfully.'
else
render :action => 'edit'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment