2012-05-02 10:18:07 +01:00
|
|
|
class Projects::SubscribesController < Projects::BaseController
|
2015-03-04 23:19:19 +00:00
|
|
|
before_action :authenticate_user!
|
2011-12-28 13:54:45 +00:00
|
|
|
|
|
|
|
load_and_authorize_resource :project
|
2014-01-21 04:51:49 +00:00
|
|
|
load_and_authorize_resource :issue, through: :project, find_by: :serial_id
|
|
|
|
load_and_authorize_resource :subscribe, through: :issue, find_by: :user_id
|
2011-12-27 12:35:31 +00:00
|
|
|
|
2011-12-26 15:48:57 +00:00
|
|
|
def create
|
2014-01-21 04:51:49 +00:00
|
|
|
@subscribe = @issue.subscribes.build(user_id: current_user.id)
|
2011-12-26 15:48:57 +00:00
|
|
|
if @subscribe.save
|
|
|
|
flash[:notice] = I18n.t("flash.subscribe.saved")
|
|
|
|
redirect_to :back
|
|
|
|
else
|
|
|
|
flash[:error] = I18n.t("flash.subscribe.saved_error")
|
|
|
|
redirect_to :back
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2011-12-28 13:54:45 +00:00
|
|
|
@subscribe.destroy
|
2011-12-26 15:48:57 +00:00
|
|
|
|
|
|
|
flash[:notice] = t("flash.subscribe.destroyed")
|
|
|
|
redirect_to :back
|
|
|
|
end
|
|
|
|
end
|