Skip to content

Instantly share code, notes, and snippets.

@karapetyan
Created July 16, 2012 17:11
Show Gist options
  • Select an option

  • Save karapetyan/3123827 to your computer and use it in GitHub Desktop.

Select an option

Save karapetyan/3123827 to your computer and use it in GitHub Desktop.
Mass-assigment attr_accessable
def create
@user = User.new
@user = (params[:user].delete("admin"))
@user.admin = (params[:user][:admin] == "1")
if @user.save
flash[:notice] = "User succesfully created!"
redirect_to [:admin, @user]
else
flash.now[:alert] = "User was not created!"
render :action => "new"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment