Created
March 7, 2012 14:38
-
-
Save rafamvc/1993514 to your computer and use it in GitHub Desktop.
Two step new example for Chris
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= simple_form_for(@model, :url => step2_two_step_new_path, :method => :post) do |form| %> | |
<%= form.input :name %> | |
<%= form.input :description %> | |
<%= form.button :submit, "Next" %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= simple_form_for(@model) do |form| %> | |
<%= form.input :name, as: :hidden %> | |
<%= form.input :description, as: :hidden %> | |
<%= form.input :extra_field %> | |
<%= form.input :extra_field2 %> | |
<%= form.button :submit, "create" %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwoStepNewController < ApplicationController | |
def new | |
@model = Model.new | |
end | |
# Make sure you add step2 as a collection method on your routes resources. | |
def step2 | |
@model = Model.new(params[:model]) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment