Skip to content

Instantly share code, notes, and snippets.

@harshamv
Forked from scarfacedeb/1.form.html.haml
Last active August 29, 2015 14:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
/ Form excerpt
= f.button t(".save"), class: "btn"
= f.button t(".publish"), class: "btn", name: "publish"
= f.button t(".test"), class: "btn", name: "test"
class MultibuttonFormConstraint
def initialize(button_name)
@button_name = button_name
end
def matches?(request)
request.params.key? @button_name
end
end
# Add new routes with appropriate constrains
resources :subscriptions do
patch '' => "subscriptions#publish", on: :member, constraints: MultibuttonFormConstraint.new(:publish)
patch '' => "subscriptions#test", on: :member, constraints: MultibuttonFormConstraint.new(:test)
end
class SubscriptionController < ApplicationController
# CRUD
def update
# process REST update
end
def publish
# process publish action
end
def test
# process test action
end
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment