Sha256: ee0023cffe6a13b6dfe900d7d898a5bdc10f4918ea76560e50d32304c3699099

Contents?: true

Size: 508 Bytes

Versions: 3

Compression:

Stored size: 508 Bytes

Contents

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

  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

end



Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radiant-reader_group-extension-1.0.1 lib/readers_controller_extensions.rb
radiant-reader_group-extension-1.0.0 lib/readers_controller_extensions.rb
radiant-reader_group-extension-0.9.0 lib/readers_controller_extensions.rb