rosa-build/app/controllers/projects/commit_subscribes_controlle...

29 lines
868 B
Ruby
Raw Normal View History

class Projects::CommitSubscribesController < Projects::BaseController
2015-03-04 23:19:19 +00:00
before_action :authenticate_user!
before_action :find_commit
2012-01-23 19:42:54 +00:00
def create
if Subscribe.subscribe_to_commit(@options)
2012-01-24 19:00:51 +00:00
flash[:notice] = I18n.t("flash.subscribe.commit.saved")
2012-01-23 19:42:54 +00:00
# TODO js
redirect_to commit_path(@project, @commit)
else
flash[:error] = I18n.t("flash.subscribe.saved_error")
redirect_to commit_path(@project, @commit)
end
end
def destroy
Subscribe.unsubscribe_from_commit(@options)
2012-01-24 19:00:51 +00:00
flash[:notice] = t("flash.subscribe.commit.destroyed")
2012-01-23 19:42:54 +00:00
redirect_to commit_path(@project, @commit)
end
protected
def find_commit
@commit = @project.repo.commit(params[:commit_id])
2014-01-21 04:51:49 +00:00
@options = {project_id: @project.id, subscribeable_id: @commit.id.hex, subscribeable_type: @commit.class.name, user_id: current_user.id}
2012-01-23 19:42:54 +00:00
end
end