Skip to content

Instantly share code, notes, and snippets.

@mbhnyc
Created March 20, 2012 16:32
Show Gist options
  • Save mbhnyc/2137965 to your computer and use it in GitHub Desktop.
Save mbhnyc/2137965 to your computer and use it in GitHub Desktop.
Routing Question
# index.html.haml
- if !@flags_profiles.empty?
= simple_form_for( f, remote: true, method: :put, url: admins_moderations_confirm_flag_path, html: { style: 'line-height: 1'} ) do |g|
= g.hidden_field :id, :value => f.id
= g.submit "Confirm Flag", html_options: {class: "moderate-photo-button", style: "color: green;"}
# routes.rb
namespace :admins do
resources :moderations
match 'moderations/confirm_flag' => 'moderations#confirm_flag', :via => :put
match 'moderations/reject_flag' => 'moderations#reject_flag', :via => :put
end
# moderations_controller.rb
class Admins::ModerationsController < ApplicationController
before_filter :authenticate_admin!
def confirm_flag
@target_flag = Flag.find(params[:flag][:id])
respond_to do |format|
format.json { head :ok }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment