Sha256: dc6bfc51f0464f16fb8745718c4ad5a462cd28368078d0448bcbc32e36b12cd4

Contents?: true

Size: 1.12 KB

Versions: 19

Compression:

Stored size: 1.12 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
    raise ActiveRecord::RecordNotFound
  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

19 entries across 19 versions & 2 rubygems

Version Path
social_stream-2.1.1 base/app/controllers/groups_controller.rb
social_stream-2.1.0 base/app/controllers/groups_controller.rb
social_stream-base-2.1.0 app/controllers/groups_controller.rb
social_stream-2.0.4 base/app/controllers/groups_controller.rb
social_stream-base-2.0.4 app/controllers/groups_controller.rb
social_stream-2.0.3 base/app/controllers/groups_controller.rb
social_stream-base-2.0.3 app/controllers/groups_controller.rb
social_stream-2.0.2 base/app/controllers/groups_controller.rb
social_stream-base-2.0.2 app/controllers/groups_controller.rb
social_stream-2.0.1 base/app/controllers/groups_controller.rb
social_stream-base-2.0.1 app/controllers/groups_controller.rb
social_stream-2.0.0 base/app/controllers/groups_controller.rb
social_stream-base-2.0.0 app/controllers/groups_controller.rb
social_stream-2.0.0.beta3 base/app/controllers/groups_controller.rb
social_stream-base-2.0.0.beta3 app/controllers/groups_controller.rb
social_stream-2.0.0.beta2 base/app/controllers/groups_controller.rb
social_stream-base-2.0.0.beta2 app/controllers/groups_controller.rb
social_stream-2.0.0.beta1 base/app/controllers/groups_controller.rb
social_stream-base-2.0.0.beta1 app/controllers/groups_controller.rb