Class: EgovUtils::GroupsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- EgovUtils::GroupsController
- Defined in:
- app/controllers/egov_utils/groups_controller.rb
Instance Method Summary collapse
- #add_users ⇒ Object
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #new_users ⇒ Object
- #update ⇒ Object
Instance Method Details
#add_users ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/egov_utils/groups_controller.rb', line 51 def add_users render_404 and return unless @group.allow_member_assign? @users = User.active.assignable_to_group(@group).where(:id => (params[:user_id] || params[:user_ids])).to_a @group.users << @users respond_to do |format| format.html { redirect_to group_path(@group) } format.json { head :ok } end end |
#create ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/egov_utils/groups_controller.rb', line 30 def create @group = Group.new(create_params) respond_to do |format| if @group.save format.html{ redirect_to egov_utils.groups_path, notice: t('success_created') } format.json{ render json: @group, status: :created } else format.html{ render 'new' } format.json{ render json: @group.errors., status: :unprocessable_entity } end end end |
#edit ⇒ Object
16 17 18 |
# File 'app/controllers/egov_utils/groups_controller.rb', line 16 def edit @group = Group.find(params[:id]) end |
#index ⇒ Object
5 6 7 8 9 10 |
# File 'app/controllers/egov_utils/groups_controller.rb', line 5 def index @groups = EgovUtils::Group. accessible_by(current_ability). order(:provider). page(params[:page] || 1) end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/egov_utils/groups_controller.rb', line 12 def new @group = Group.new end |
#new_users ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/controllers/egov_utils/groups_controller.rb', line 43 def new_users @principals = EgovUtils::User.active.assignable_to_group(@group) respond_to do |format| format.html format.js { render_modal_js } end end |
#update ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/egov_utils/groups_controller.rb', line 20 def update @group = Group.find(params[:id]) if @group.update(update_params) redirect_to egov_utils.groups_path, notice: t('success_updated') else render :edit end end |