Followed along with Railscast 038 Multibutton Form
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
bin
config
db
lib
log
public
test
vendor/assets
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru

README.md

038 Multibutton Form

Followed along with Railscast 038 Multibutton Form

Blog Post @ PatrickPerey.com

<% if params[:preview_button] %>
  <div id="preview">
    <h2><%= @project.name %></h2>
    <%= textilize @project.description %>
  </div>
<% end %>
...
<%= submit_tag 'Preview', name: 'preview_button' %>
def create
...
  respond_to do |format|
    if params[:preview_button] || !@project.save
      format.html { render action: 'new' }
      format.json { render json: @project.errors, status: :unprocessable_entity }
    else
      format.html { redirect_to @project, notice: 'Project was successfully created.' }
      format.json { render action: 'show', status: :created, location: @project }
    end
  end
end