Sha256: aae0c912b507ca61f2def465e76405fa1ccd84d9177afc8a96dc792ccff14941
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
class UsersController < ApplicationController include Applicat::Mvc::Controller::Resource before_filter :find_resource, only: [:show, :edit, :preferences, :update, :destroy] respond_to :html, :js, :json def index parent = find_parent User::PARENT_TYPES @users = parent ? parent.users : User.all end def languages render json: User.languages(params[:q]).to_json and return end def show end def edit @user.attributes = params[:user] if params[:user].present? end def preferences raise CanCan::AccessDenied if !current_user || (current_user.id != @user.id && !current_user.roles?(:master)) if params[:user] && @user.update_attributes(params[:user]) redirect_to preferences_user_path(@user), notice: t('general.form.successfully_updated') and return end end def update raise CanCan::AccessDenied if !current_user || (current_user.id != @user.id && !current_user.roles?(:master)) if @user.update_attributes(params[:user]) redirect_to edit_user_path(@user), notice: t('general.form.successfully_updated') else render :edit end end def destroy raise CanCan::AccessDenied if !current_user || (current_user.id != @user.id && !current_user.roles?(:master)) @user.destroy redirect_to users_url, notice: t('general.form.destroyed') end def resource @user end private def find_resource @user = User.friendly.find(params[:id]) @presenter = Resources::User::FormPresenter.new(self.view_context, resource: resource) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
voluntary-0.7.1 | app/controllers/users_controller.rb |
voluntary-0.7.0 | app/controllers/users_controller.rb |