Skip to content

Commit

Permalink
Add set_holder filter to visitors controller index and agenda actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Senen committed Jan 10, 2018
1 parent 35facef commit e477409
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/controllers/visitors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class VisitorsController < ApplicationController

require 'ext/string'
before_filter :set_holder, only: [:index, :agenda]

def index
get_events
Expand All @@ -13,7 +14,6 @@ def show
end

def agenda
@holder = Holder.where(id: params[:holder]).first
if @holder.blank?
redirect_to visitors_path, alert: t('activerecord.models.holder.not_found')
else
Expand All @@ -28,6 +28,10 @@ def update_holders

private

def set_holder
@holder = Holder.where(id: params[:holder]).first
end

def get_events
@events = search(params)
@paginated_events = Event.published.includes(:position => [:holder,:area]).
Expand Down
2 changes: 1 addition & 1 deletion app/views/visitors/headline/_holder.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<p>
<span class="keywords"><%= t('main.events_for') %> </span>
<strong class="result-m mb20">
<%= link_to @holder.full_name, agenda_path(@holder.id, @holder.full_name.parameterize) if @holder.present? %>
<%= link_to @holder.full_name, agenda_path(@holder.id, @holder.full_name.parameterize) %>
</strong>
</p>
</div>

0 comments on commit e477409

Please sign in to comment.