Sha256: 81f58ab7d6ca7631cf9a93450c4b80783c73a4b3eacb6bb511223b6703b72219
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
module Gluttonberg module Public class FlagController < Gluttonberg::Public::BaseController def new model = params[:flaggable_type].constantize @flaggable = model.where(:id => params[:flaggable_id]).first respond_to do |format| format.html end end def create flag = current_user.flags.create params[:flag] flash[:notice] = if flag.new_record? "You already flagged this content!" else # success "Content has been flagged!" end respond_to do |format|# note: you'll need to ensure that this route exists format.html { url = "" begin if flag.flaggable.respond_to?(:commentable) url = polymorphic_path(flag.flaggable.commentable) else url = polymorphic_path(flag.flaggable) end flag.update_attributes(:url => url) redirect_to url rescue => e end } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems