Module: TinyCore::Controllers::Users
- Defined in:
- lib/tiny_core/controllers/users.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(receiver) ⇒ Object
4 5 6 |
# File 'lib/tiny_core/controllers/users.rb', line 4 def self.included(receiver) receiver.before_filter :login_required, :only => [:index, :show, :edit, :update] end |
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tiny_core/controllers/users.rb', line 16 def create if logged_in? && current_user.respond_to?(:current_account) @user = current_user.current_account.users.build(params[:user]) @user.current_account = current_user.current_account else @user = User.new(params[:user]) end if @user.save flash[:notice] = I18n.t('flash.notice.created_user') if logged_in? @user.accounts << current_user.current_account if current_user.respond_to?(:current_account) redirect_to new_user_path else redirect_back_or_default root_path end else render :action => :new end end |
#edit ⇒ Object
42 43 44 |
# File 'lib/tiny_core/controllers/users.rb', line 42 def edit @user = User.find(params[:id]) end |
#index ⇒ Object
8 9 10 |
# File 'lib/tiny_core/controllers/users.rb', line 8 def index redirect_to account_path(current_user.current_account) end |
#new ⇒ Object
12 13 14 |
# File 'lib/tiny_core/controllers/users.rb', line 12 def new @user = User.new end |
#show ⇒ Object
38 39 40 |
# File 'lib/tiny_core/controllers/users.rb', line 38 def show @user = User.find(params[:id]) end |
#update ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/tiny_core/controllers/users.rb', line 46 def update @user = User.find(params[:id]) if @user.update_attributes(params[:user]) flash[:notice] = I18n.t('flash.notice.updated_user') redirect_to root_path else render :action => :edit end end |