Sha256: ebd826a17d2b4429d97472e8f32b3aa970747c382ac4fc59c040954e7a17f762

Contents?: true

Size: 508 Bytes

Versions: 8

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_edit_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

8 entries across 8 versions & 1 rubygems

Version Path
radiant-reader_group-extension-1.2.4 lib/readers_controller_extensions.rb
radiant-reader_group-extension-1.2.3 lib/readers_controller_extensions.rb
radiant-reader_group-extension-1.2.2 lib/readers_controller_extensions.rb
radiant-reader_group-extension-1.2.1 lib/readers_controller_extensions.rb
radiant-reader_group-extension-1.2.0 lib/readers_controller_extensions.rb
radiant-reader_group-extension-1.1.2 lib/readers_controller_extensions.rb
radiant-reader_group-extension-1.1.1 lib/readers_controller_extensions.rb
radiant-reader_group-extension-1.1.0 lib/readers_controller_extensions.rb