Sha256: 31b085aae42a6b42e19061ce59d36954751259091aeac0ba5147d62932a5121e

Contents?: true

Size: 1.34 KB

Versions: 108

Compression:

Stored size: 1.34 KB

Contents

class GroupsController < ApplicationController
  include SocialStream::Controllers::Subjects

  before_filter :authenticate_user!, :except => [ :index, :show ]

  # Set group founder to current_subject
  # Must do before authorization
  before_filter :set_founder, :only => [ :new, :create ]

  load_and_authorize_resource

  respond_to :html, :js

  def index
    @groups = Group.most(params[:most]).
                    alphabetic.
                    letter(params[:letter]).
                    name_search(params[:search]).
                    tagged_with(params[:tag]).
                    page(params[:page]).per(10)

  end

  def create
    create! do |success, failure|
      success.html {
        self.current_subject = @group
        redirect_to :home
      }
    end
  end

  def destroy
    destroy! do |success, failure|
      success.html {
        self.current_subject = current_user
        redirect_to :home
      }
    end
  end

  protected

  # Overwrite resource method to support slug
  # See InheritedResources::BaseHelpers#resource
  def resource
    @group ||= end_of_association_chain.find_by_slug!(params[:id])
  end

  private

  def set_founder
    params[:group]                  ||= {}
    params[:group][:author_id]      ||= current_subject.try(:actor_id)
    params[:group][:user_author_id] ||= current_user.try(:actor_id)
  end
end

Version data entries

108 entries across 108 versions & 2 rubygems

Version Path
social_stream-1.1.12 base/app/controllers/groups_controller.rb
social_stream-base-1.1.11 app/controllers/groups_controller.rb
social_stream-1.1.11 base/app/controllers/groups_controller.rb
social_stream-base-1.1.10 app/controllers/groups_controller.rb
social_stream-1.1.10 base/app/controllers/groups_controller.rb
social_stream-base-1.1.9 app/controllers/groups_controller.rb
social_stream-1.1.9 base/app/controllers/groups_controller.rb
social_stream-base-1.1.8 app/controllers/groups_controller.rb
social_stream-1.1.8 base/app/controllers/groups_controller.rb
social_stream-base-1.1.7 app/controllers/groups_controller.rb
social_stream-1.1.7 base/app/controllers/groups_controller.rb
social_stream-base-1.1.6 app/controllers/groups_controller.rb
social_stream-1.1.6 base/app/controllers/groups_controller.rb
social_stream-base-1.1.5 app/controllers/groups_controller.rb
social_stream-1.1.5 base/app/controllers/groups_controller.rb
social_stream-base-1.1.4 app/controllers/groups_controller.rb
social_stream-1.1.4 base/app/controllers/groups_controller.rb
social_stream-1.1.3 base/app/controllers/groups_controller.rb
social_stream-base-1.1.3 app/controllers/groups_controller.rb
social_stream-1.1.2 base/app/controllers/groups_controller.rb