Added slug to polls for named urls

This commit is contained in:
María Checa
2017-10-08 17:51:33 +02:00
committed by Javi Martín
parent 525eb9034c
commit e3b16230e6
6 changed files with 25 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
class PollsController < ApplicationController
include PollsHelper
before_action :load_poll, except: [:index]
before_action :load_active_poll, only: :index
load_and_authorize_resource
@@ -40,6 +41,10 @@ class PollsController < ApplicationController
private
def load_poll
@poll = Poll.find_by(slug: params[:id]) || Poll.find_by(id: params[:id])
end
def load_active_poll
@active_poll = ActivePoll.first
end