Sha256: b3915fe563601b10cd7872446481b132ac2d1d0e3c2f0fd2550a31671731bdbd

Contents?: true

Size: 877 Bytes

Versions: 1

Compression:

Stored size: 877 Bytes

Contents

  # POST /<%= plural_name %>
  <%- if xml? -%>
  # POST /<%= plural_name %>.xml
  <%- end -%>
  def create
    @<%= singular_name %> = <%= class_name %>.new(params[:<%= singular_name %>])

    <%- if xml? -%>
    respond_to do |format|
      if @<%= singular_name %>.save
        set_flash
        format.html { redirect_to(<%= item_path('url') %>) }
        format.xml  { render :xml => @<%= singular_name %>, :status => :created, :location => @<%= singular_name %> }
      else
        set_flash_now :error, :failed
        format.html { render :new }
        format.xml  { render :xml => @<%= singular_name %>.errors, :status => :unprocessable_entity }
      end
    end
    <%- else -%>
    if @<%= singular_name %>.save
      set_flash
      redirect_to(<%= item_path('url') %>)
    else
      set_flash_now :error, :failed
      render :new
    end
    <%- end -%>
  end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iain-pizza-generators-0.1.4 rails_generators/pizza_scaffold/templates/actions/create.rb