Sha256: c527911960b7b2760f3c275121dfc8c27ca7f78ed1b8f2a81c70186dd001bca6
Contents?: true
Size: 1.3 KB
Versions: 6
Compression:
Stored size: 1.3 KB
Contents
class GroupsController < InheritedResources::Base before_filter :authenticate_user!, :except => [ :index, :show ] # Set group founder to current_subject # Must do before authorization before_filter :set_founder, :only => :new 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 show 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
6 entries across 6 versions & 2 rubygems