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

Ticket #8278: scaffolding_with_multiple_extensions.patch

File scaffolding_with_multiple_extensions.patch, 14.1 kB (added by tpope, 2 years ago)
  • lib/rails_generator/generators/components/scaffold/scaffold_generator.rb

    old new  
    8181      m.dependency 'model', [singular_name], :collision => :skip, :skip_migration => true 
    8282 
    8383      # Scaffolded forms. 
    84       m.complex_template "form.erb", 
     84      m.complex_template "form.html.erb", 
    8585        File.join('app/views', 
    8686                  controller_class_path, 
    8787                  controller_file_name, 
    88                   "_form.erb"), 
    89         :insert => 'form_scaffolding.erb', 
     88                  "_form.html.erb"), 
     89        :insert => 'form_scaffolding.html.erb', 
    9090        :sandbox => lambda { create_sandbox }, 
    9191        :begin_mark => 'form', 
    9292        :end_mark => 'eoform', 
     
    9595 
    9696      # Scaffolded views. 
    9797      scaffold_views.each do |action| 
    98         m.template "view_#{action}.erb", 
     98        m.template "view_#{action}.html.erb", 
    9999                   File.join('app/views', 
    100100                             controller_class_path, 
    101101                             controller_file_name, 
    102                              "#{action}.erb"), 
     102                             "#{action}.html.erb"), 
    103103                   :assigns => { :action => action } 
    104104      end 
    105105 
     
    120120                            "#{controller_file_name}_helper.rb") 
    121121 
    122122      # Layout and stylesheet. 
    123       m.template 'layout.erb', 
     123      m.template 'layout.html.erb', 
    124124                  File.join('app/views/layouts', 
    125125                            controller_class_path, 
    126                             "#{controller_file_name}.erb") 
     126                            "#{controller_file_name}.html.erb") 
    127127 
    128128      m.template 'style.css',     'public/stylesheets/scaffold.css' 
    129129 
     
    133133        path = File.join('app/views', 
    134134                          controller_class_path, 
    135135                          controller_file_name, 
    136                           "#{action}.erb") 
    137         m.template "controller:view.erb", path, 
     136                          "#{action}.html.erb") 
     137        m.template "controller:view.html.erb", path, 
    138138                   :assigns => { :action => action, :path => path} 
    139139      end 
    140140    end 
  • lib/rails_generator/generators/components/scaffold/templates/view_show.erb

    old new  
    1 <%% for column in <%= model_name %>.content_columns %> 
    2 <p> 
    3   <b><%%= column.human_name %>:</b> <%%=h @<%= singular_name %>.send(column.name) %> 
    4 </p> 
    5 <%% end %> 
    6  
    7 <%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => @<%= singular_name %> %> | 
    8 <%%= link_to 'Back', :action => 'list<%= suffix %>' %> 
  • lib/rails_generator/generators/components/scaffold/templates/layout.erb

    old new  
    1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    2        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    3  
    4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    5 <head> 
    6   <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
    7   <title><%= controller_class_name %>: <%%= controller.action_name %></title> 
    8   <%%= stylesheet_link_tag 'scaffold' %> 
    9 </head> 
    10 <body> 
    11  
    12 <p style="color: green"><%%= flash[:notice] %></p> 
    13  
    14 <%%= yield  %> 
    15  
    16 </body> 
    17 </html> 
  • lib/rails_generator/generators/components/scaffold/templates/view_edit.erb

    old new  
    1 <h1>Editing <%= singular_name %></h1> 
    2  
    3 <%% form_tag :action => 'update<%= @suffix %>', :id => @<%= singular_name %> do %> 
    4   <%%= render :partial => 'form' %> 
    5   <%%= submit_tag 'Edit' %> 
    6 <%% end %> 
    7  
    8 <%%= link_to 'Show', :action => 'show<%= suffix %>', :id => @<%= singular_name %> %> | 
    9 <%%= link_to 'Back', :action => 'list<%= suffix %>' %> 
  • lib/rails_generator/generators/components/scaffold/templates/view_new.erb

    old new  
    1 <h1>New <%= singular_name %></h1> 
    2  
    3 <%% form_tag :action => 'create<%= @suffix %>' do %> 
    4   <%%= render :partial => 'form' %> 
    5   <%%= submit_tag "Create" %> 
    6 <%% end %> 
    7  
    8 <%%= link_to 'Back', :action => 'list<%= suffix %>' %> 
  • lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.erb

    old new  
  • lib/rails_generator/generators/components/scaffold/templates/form.erb

    old new  
    1 <%%= error_messages_for '<%= singular_name %>' %> 
    2  
    3 <%= template_for_inclusion %> 
  • lib/rails_generator/generators/components/scaffold/templates/view_list.erb

    old new  
    1 <h1>Listing <%= plural_name %></h1> 
    2  
    3 <table> 
    4   <tr> 
    5   <%% for column in <%= model_name %>.content_columns %> 
    6     <th><%%= column.human_name %></th> 
    7   <%% end %> 
    8   </tr> 
    9    
    10 <%% for <%= singular_name %> in @<%= plural_name %> %> 
    11   <tr> 
    12   <%% for column in <%= model_name %>.content_columns %> 
    13     <td><%%=h <%= singular_name %>.send(column.name) %></td> 
    14   <%% end %> 
    15     <td><%%= link_to 'Show', :action => 'show<%= suffix %>', :id => <%= singular_name %> %></td> 
    16     <td><%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => <%= singular_name %> %></td> 
    17     <td><%%= link_to 'Destroy', { :action => 'destroy<%= suffix %>', :id => <%= singular_name %> }, :confirm => 'Are you sure?', :method => :post %></td> 
    18   </tr> 
    19 <%% end %> 
    20 </table> 
    21  
    22 <%%= link_to 'Previous page', { :page => @<%= singular_name %>_pages.current.previous } if @<%= singular_name %>_pages.current.previous %> 
    23 <%%= link_to 'Next page', { :page => @<%= singular_name %>_pages.current.next } if @<%= singular_name %>_pages.current.next %>  
    24  
    25 <br /> 
    26  
    27 <%%= link_to 'New <%= singular_name %>', :action => 'new<%= suffix %>' %> 
  • lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb

    old new  
    4141 
    4242      for action in scaffold_views 
    4343        m.template( 
    44           "view_#{action}.erb", 
    45           File.join('app/views', controller_class_path, controller_file_name, "#{action}.erb") 
     44          "view_#{action}.html.erb", 
     45          File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.erb") 
    4646        ) 
    4747      end 
    4848 
    4949      # Layout and stylesheet. 
    50       m.template('layout.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.erb")) 
     50      m.template('layout.html.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb")) 
    5151      m.template('style.css', 'public/stylesheets/scaffold.css') 
    5252 
    5353      m.template('model.rb', File.join('app/models', class_path, "#{file_name}.rb")) 
  • lib/rails_generator/generators/components/scaffold_resource/templates/view_show.erb

    old new  
    1 <% for attribute in attributes -%> 
    2 <p> 
    3   <b><%= attribute.column.human_name %>:</b> 
    4   <%%=h @<%= singular_name %>.<%= attribute.name %> %> 
    5 </p> 
    6  
    7 <% end -%> 
    8  
    9 <%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> | 
    10 <%%= link_to 'Back', <%= plural_name %>_path %> 
  • lib/rails_generator/generators/components/scaffold_resource/templates/layout.erb

    old new  
    1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    2        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    3  
    4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    5 <head> 
    6   <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
    7   <title><%= controller_class_name %>: <%%= controller.action_name %></title> 
    8   <%%= stylesheet_link_tag 'scaffold' %> 
    9 </head> 
    10 <body> 
    11  
    12 <p style="color: green"><%%= flash[:notice] %></p> 
    13  
    14 <%%= yield  %> 
    15  
    16 </body> 
    17 </html> 
  • lib/rails_generator/generators/components/scaffold_resource/templates/controller.rb

    old new  
    55    @<%= table_name %> = <%= class_name %>.find(:all) 
    66 
    77    respond_to do |format| 
    8       format.html # index.erb 
     8      format.html # index.html.erb 
    99      format.xml  { render :xml => @<%= table_name %> } 
    1010    end 
    1111  end 
     
    1616    @<%= file_name %> = <%= class_name %>.find(params[:id]) 
    1717 
    1818    respond_to do |format| 
    19       format.html # show.erb 
     19      format.html # show.html.erb 
    2020      format.xml  { render :xml => @<%= file_name %> } 
    2121    end 
    2222  end 
     
    2727    @<%= file_name %> = <%= class_name %>.new 
    2828 
    2929    respond_to do |format| 
    30       format.html # new.erb 
     30      format.html # new.html.erb 
    3131      format.xml  { render :xml => @<%= file_name %> } 
    3232    end 
    3333  end 
  • lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.erb

    old new  
    1 <h1>Editing <%= singular_name %></h1> 
    2  
    3 <%%= error_messages_for :<%= singular_name %> %> 
    4  
    5 <%% form_for(:<%= singular_name %>, :url => <%= singular_name %>_path(@<%= singular_name %>), :html => { :method => :put }) do |f| %> 
    6 <% for attribute in attributes -%> 
    7   <p> 
    8     <b><%= attribute.column.human_name %></b><br /> 
    9     <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> 
    10   </p> 
    11  
    12 <% end -%> 
    13   <p> 
    14     <%%= submit_tag "Update" %> 
    15   </p> 
    16 <%% end %> 
    17  
    18 <%%= link_to 'Show', <%= singular_name %>_path(@<%= singular_name %>) %> | 
    19 <%%= link_to 'Back', <%= plural_name %>_path %> 
  • lib/rails_generator/generators/components/scaffold_resource/templates/view_new.erb

    old new  
    1 <h1>New <%= singular_name %></h1> 
    2  
    3 <%%= error_messages_for :<%= singular_name %> %> 
    4  
    5 <%% form_for(:<%= singular_name %>, :url => <%= plural_name %>_path) do |f| %> 
    6 <% for attribute in attributes -%> 
    7   <p> 
    8     <b><%= attribute.column.human_name %></b><br /> 
    9     <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> 
    10   </p> 
    11  
    12 <% end -%> 
    13   <p> 
    14     <%%= submit_tag "Create" %> 
    15   </p> 
    16 <%% end %> 
    17  
    18 <%%= link_to 'Back', <%= plural_name %>_path %> 
  • lib/rails_generator/generators/components/scaffold_resource/templates/view_index.erb

    old new  
    1 <h1>Listing <%= plural_name %></h1> 
    2  
    3 <table> 
    4   <tr> 
    5 <% for attribute in attributes -%> 
    6     <th><%= attribute.column.human_name %></th> 
    7 <% end -%> 
    8   </tr> 
    9    
    10 <%% for <%= singular_name %> in @<%= plural_name %> %> 
    11   <tr> 
    12 <% for attribute in attributes -%> 
    13     <td><%%=h <%= singular_name %>.<%= attribute.name %> %></td> 
    14 <% end -%> 
    15     <td><%%= link_to 'Show', <%= singular_name %>_path(<%= singular_name %>) %></td> 
    16     <td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td> 
    17     <td><%%= link_to 'Destroy', <%= singular_name %>_path(<%= singular_name %>), :confirm => 'Are you sure?', :method => :delete %></td> 
    18   </tr> 
    19 <%% end %> 
    20 </table> 
    21  
    22 <br /> 
    23  
    24 <%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>