Module: Kinney::Concerns::Controllers::ClipsController
- Extended by:
- ActiveSupport::Concern
- Included in:
- Kinney::ClipsController
- Defined in:
- lib/concerns/controllers/clips_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
7 8 9 10 |
# File 'lib/concerns/controllers/clips_controller.rb', line 7 def index @people = Kinney::Person.with_clips @clips = Kinney::Clip.all end |
#show ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/concerns/controllers/clips_controller.rb', line 12 def show @clip = Kinney::Clip.friendly.includes(:people).find(params[:id]) # If an old id or a numeric id was used to find the record, then # the request path will not match the clip_path, and we should do # a 301 redirect that uses the current friendly id. if !@clip.slug.blank? and params[:id] != @clip.slug return redirect_to @clip, :status => :moved_permanently end assign_webvtt # find people with clips associated with this clip clip_people_ids = @clip.people.pluck(:person_id) # FIXME this could probably be optimized for finding just 8 random resources. But can it be done # in a non-database dependent way? @people = Kinney::Person.with_clips.where(Arel::Table.new(:kinney_people)[:id].not_in clip_people_ids).shuffle[0..8] @people_clips = @clip.people.map{|person| person.clips}.flatten.uniq @topic_clips = @clip. @meta_description = @clip.description end |