Sha256: 052cab05760a7b613e6d45ef47cc21b28e6cc59e93227e8d3776c7812ccde6d4

Contents?: true

Size: 1.23 KB

Versions: 22

Compression:

Stored size: 1.23 KB

Contents

class <%= plural_name.camelize %>::New < Mustache::Rails

  <%# TODO: extract errors_display settings to to module methods -%>
def errors_display_div
    return "" unless <%= singular_name %>.errors.any?
    content_tag("div", :id=>"errorExplanation", :class=>"errorExplanation") do
      content_tag("h2", error_header) + content_tag("ul") do 
        <%= singular_name %>.errors.full_messages.inject("") do |memo,msg|
          memo += content_tag("li", msg)
        end
      end
    end
  end
  
def <%= singular_name %>_form_tag
    form_tag(create_path, :class => "<%= singular_name %>_form", :id => "edit_<%= singular_name %>_#{<%= singular_name %>.id}_form")
  end
  
<% for attribute in attributes -%>
def <%= attribute.name %>_label
    label :<%= singular_name %>, :<%= attribute.name %>
  end
  <%# TODO: Different fields for different attribute types -%>
  
def <%= attribute.name %>_text_field
    text_field(:<%= singular_name %>, :<%= attribute.name %>, :id => "<%= attribute.name %>_text_field")
  end

<% end -%>

  def form_submit
    submit_tag "Create"
  end

  
  def index_path
    <%= plural_name %>_path
  end
  
  private
  
  def create_path
    <%= plural_name %>_path
  end
  
  def error_header
    "u r dong it rong"
  end
  
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
rails3-generators-1.0.0 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.17.6 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.17.5 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.17.4 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.17.3 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.17.2 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.17.1 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.17.0 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.16.1 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.16.0 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.15.0 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.14.0 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.13.0 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.12.1 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.12.0 lib/generators/mustache/scaffold/templates/new.rb.erb
mustache_rails3-0.1.2.1 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.11.0 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.10.3 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.10.2 lib/generators/mustache/scaffold/templates/new.rb.erb
rails3-generators-0.10.1 lib/generators/mustache/scaffold/templates/new.rb.erb