Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## users_controller.rb
- class UsersController < ApplicationController
- # Be sure to include AuthenticationSystem in Application Controller instead
- include AuthenticatedSystem
- # If you want "remember me" functionality, add this before_filter to Application Controller
- before_filter :login_from_cookie
- # render new.rhtml
- def new
- end
- def create
- @user = User.new(params[:user])
- @user.save!
- self.current_user = @user
- redirect_back_or_default('/')
- flash[:notice] = "Thanks for signing up!"
- rescue ActiveRecord::RecordInvalid
- render :action => 'new'
- end
- def index
- @user_pages, @users = paginate :users, :per_page => 10
- end
- def edit
- @user = User.find(params[:id])
- end
- def update
- flash[:notice] = "Nothing updated... no action yet"
- redirect_back_or_default('/')
- end
- end
- ## edit.rhtml
- <h2>Edit <%= @user.login %></h2>
- <% form_tag :url => user_path(@user), :html => {:method => :put} do %>
- <%= error_messages_for 'user' %>
- <!--[form:user]-->
- <p><label for="user_login"><b>Login:</b></label> <%= @user.login %></p>
- <p><label for="user_password">Change password:</label><br/>
- <%= password_field 'user', 'password' %></p>
- <p><label for="user_password_confirmation">Confirm:<label><br/>
- <%= password_field 'user', 'password_confirmation' %></p>
- <!--[eoform:user]-->
- <%= submit_tag 'Edit' %>
- <% end %>
- <%= link_to 'Show', user_path(@user) %> |
- <%= link_to 'Back', :action => 'index' %>
Add Comment
Please, Sign In to add comment