Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7086: scaffold_resource_path.diff

File scaffold_resource_path.diff, 1.7 kB (added by bscofield, 2 years ago)

Adds form partial; updates new and edit views to use the new partial

  • scaffold_resource_generator.rb

    old new  
    8383    end 
    8484 
    8585    def scaffold_views 
    86       %w[ index show new edit
     86      %w[ index show new edit _form
    8787    end 
    8888 
    8989    def model_name  
  • templates/view_edit.rhtml

    old new  
    33<%%= error_messages_for :<%= singular_name %> %> 
    44 
    55<%% form_for(:<%= singular_name %>, :url => <%= singular_name %>_path(@<%= singular_name %>), :html => { :method => :put }) do |f| %> 
    6 <% for attribute in attributes -%> 
     6  <%%= render :partial => 'form', :locals => {:f => f} %> 
    77  <p> 
    8     <b><%= attribute.column.human_name %></b><br /> 
    9     <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> 
    10   </p> 
    11  
    12 <% end -%> 
    13   <p> 
    148    <%%= submit_tag "Update" %> 
    159  </p> 
    1610<%% end %> 
  • templates/view_new.rhtml

    old new  
    33<%%= error_messages_for :<%= singular_name %> %> 
    44 
    55<%% form_for(:<%= singular_name %>, :url => <%= plural_name %>_path) do |f| %> 
    6 <% for attribute in attributes -%> 
     6  <%%= render :partial => 'form', :locals => {:f => f} %> 
    77  <p> 
    8     <b><%= attribute.column.human_name %></b><br /> 
    9     <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> 
    10   </p> 
    11  
    12 <% end -%> 
    13   <p> 
    148    <%%= submit_tag "Create" %> 
    159  </p> 
    1610<%% end %>