Sha256: 37d756add42596cbee6624a02164740139c4bbc8f31b50706fde168a264660ea

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module SocialStream
  module Controllers
    module Objects
      extend ActiveSupport::Concern

      included do
        inherit_resources

        before_filter :set_author_ids, :only => [ :new, :create, :update ]

	after_filter :increment_visit_count, :only => :show

        load_and_authorize_resource :except => :index

        respond_to :html, :js

        # destroy method must be before the one provided by inherited_resources
        include SocialStream::Controllers::Objects::UpperInstanceMethods
      end

      # Methods that should be included after the included block
      module UpperInstanceMethods
        def destroy
          @post_activity = resource.post_activity

          destroy!
        end
      end

      protected

      def increment_visit_count
        resource.activity_object.increment!(:visit_count) if request.format == 'html'
      end

      def set_author_ids
        resource_params.first[:author_id] = current_subject.try(:actor_id)
        resource_params.first[:user_author_id] = current_user.try(:actor_id)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
social_stream-0.26.0 base/lib/social_stream/controllers/objects.rb
social_stream-base-0.20.0 lib/social_stream/controllers/objects.rb