Skip to content

Instantly share code, notes, and snippets.

@delba
Created May 9, 2013 17:34
Show Gist options
  • Select an option

  • Save delba/5549106 to your computer and use it in GitHub Desktop.

Select an option

Save delba/5549106 to your computer and use it in GitHub Desktop.
Using multiple submit buttons
class ItemsController < ApplicationController
def create
@item = Item.create!(item_params)
end
private
def item_params
params.require(:item).permit(:name, :public)
end
end
<%= form_for @item do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.button "Create Private Item", name: "item[public]", value: false %>
<%= f.button "Create Public Item", name: "item[public]", value: true %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment