Added slug to polls for named urls
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user