Class: Gluttonberg::Public::FlagController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- BaseController
- Gluttonberg::Public::FlagController
- Defined in:
- app/controllers/gluttonberg/public/flag_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/gluttonberg/public/flag_controller.rb', line 13 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 |
#new ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/controllers/gluttonberg/public/flag_controller.rb', line 5 def new model = params[:flaggable_type].constantize @flaggable = model.where(:id => params[:flaggable_id]).first respond_to do |format| format.html end end |