Files
grecia/app/controllers/admin/poll/active_polls_controller.rb
Javi Martín 27468b0b7b Use relative URLs where possible
In general, we always use relative URLs (using `_path`), but sometimes
we were accidentally using absolute URLs (using `_url`). It's been
reported i might cause some isuses if accepting both HTTP and HTTPS
connections, although we've never seen the case.

In any case, this change makes the code more consistent and makes the
generated HTML cleaner.
2019-10-20 17:26:14 +02:00

36 lines
731 B
Ruby

class Admin::Poll::ActivePollsController < Admin::Poll::BaseController
include Translatable
before_action :load_active_poll
def create
if @active_poll.update(active_poll_params)
redirect_to admin_polls_path, notice: t("flash.actions.update.active_poll")
else
render :edit
end
end
def edit
end
def update
if @active_poll.update(active_poll_params)
redirect_to admin_polls_path, notice: t("flash.actions.update.active_poll")
else
render :edit
end
end
private
def load_active_poll
@active_poll = ::ActivePoll.first_or_initialize
end
def active_poll_params
params.require(:active_poll).permit(translation_params(ActivePoll))
end
end