2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-12-26 15:48:57 +00:00
|
|
|
class SubscribesController < ApplicationController
|
2011-12-27 12:35:31 +00:00
|
|
|
before_filter :authenticate_user!
|
2011-12-28 13:54:45 +00:00
|
|
|
|
|
|
|
load_and_authorize_resource :project
|
|
|
|
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
|
2011-12-28 13:54:45 +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
|