Class: Admin::MembershipsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::MembershipsController
- Defined in:
- app/controllers/admin/memberships_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/admin/memberships_controller.rb', line 9 def create @reader = Reader.find(params[:reader_id]) raise ActiveRecord::RecordNotFound unless @reader @membership = Membership.find_or_create_by_reader_id_and_group_id(@reader.id, @group.id) respond_to do |format| format.html { flash[:notice] = "#{@reader.name} added to group #{@group.name}" redirect_to admin_group_url(@group) } format.js { render :partial => 'reader' } end end |
#destroy ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/admin/memberships_controller.rb', line 22 def destroy @membership = @group.memberships.find(params[:id]) @reader = @membership.reader @membership.delete if @membership respond_to do |format| format.html { flash[:notice] = "#{@reader.name} removed from group #{@group.name}" if @membership redirect_to admin_group_url(@group) } format.js { render :partial => 'reader' } end end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/admin/memberships_controller.rb', line 5 def index redirect_to admin_group_url(@group) end |