Module: ReadersControllerExtensions

Defined in:
lib/readers_controller_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
# File 'lib/readers_controller_extensions.rb', line 3

def self.included(base)
  base.class_eval { before_filter :ensure_groups_subscribable, :only => [:update, :create] }
  base.add_edit_partial 'readers/memberships'
end

Instance Method Details

#ensure_groups_subscribableObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/readers_controller_extensions.rb', line 8

def ensure_groups_subscribable
  if params[:reader] && params[:reader][:group_ids]
    params[:reader][:group_ids].each do |g|
      raise ActiveRecord::RecordNotFound unless Group.find(g).public?
    end
  end
  true
rescue ActiveRecord::RecordNotFound
  false
end