diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-02 20:13:02 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-02 20:13:02 +0000 |
commit | 32c0e895bfa521acdc5c7031a2285a3b8dd53130 (patch) | |
tree | 5e51c893bafc763965c722638fb322f1c7d49b23 | |
parent | 3162f386dcf39c8914cc5eb9858772f4ef10aab7 (diff) | |
download | rails-32c0e895bfa521acdc5c7031a2285a3b8dd53130.tar.gz rails-32c0e895bfa521acdc5c7031a2285a3b8dd53130.tar.bz2 rails-32c0e895bfa521acdc5c7031a2285a3b8dd53130.zip |
Fixed scaffolding to use the latest style
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1380 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
7 files changed, 24 insertions, 20 deletions
diff --git a/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml b/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml index 77eecdf9d6..3dda1feec0 100644 --- a/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml +++ b/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml @@ -59,6 +59,8 @@ </head> <body> +<p style="color: green"><%= flash['notice'] %></p> + <%= @content_for_layout %> </body> diff --git a/actionpack/lib/action_controller/templates/scaffolds/list.rhtml b/actionpack/lib/action_controller/templates/scaffolds/list.rhtml index df1b7f8e4c..233e9da87d 100644 --- a/actionpack/lib/action_controller/templates/scaffolds/list.rhtml +++ b/actionpack/lib/action_controller/templates/scaffolds/list.rhtml @@ -14,7 +14,7 @@ <% end %> <td><%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => entry.id %></td> <td><%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => entry.id %></td> - <td><%= link_to "Destroy", :action => "destroy#{@scaffold_suffix}", :id => entry.id %></td> + <td><%= link_to "Destroy", :action => "destroy#{@scaffold_suffix}", :id => entry.id, :confirm => "Are you sure?" %></td> </tr> <% end %> </table> diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb b/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb index 4959674976..9aa33e472e 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb @@ -2,7 +2,7 @@ class <%= controller_class_name %>Controller < ApplicationController <% unless suffix -%> def index list - render_action 'list' + render :action => 'list' end <% end -%> @@ -16,7 +16,7 @@ class <%= controller_class_name %>Controller < ApplicationController end def show<%= suffix %> - @<%= singular_name %> = <%= model_name %>.find(@params[:id]) + @<%= singular_name %> = <%= model_name %>.find(params[:id]) end def new<%= suffix %> @@ -24,31 +24,31 @@ class <%= controller_class_name %>Controller < ApplicationController end def create<%= suffix %> - @<%= singular_name %> = <%= model_name %>.new(@params[:<%= singular_name %>]) + @<%= singular_name %> = <%= model_name %>.new(params[:<%= singular_name %>]) if @<%= singular_name %>.save - flash['notice'] = '<%= model_name %> was successfully created.' + flash[:notice] = '<%= model_name %> was successfully created.' redirect_to :action => 'list<%= suffix %>' else - render_action 'new<%= suffix %>' + render :action => 'new<%= suffix %>' end end def edit<%= suffix %> - @<%= singular_name %> = <%= model_name %>.find(@params[:id]) + @<%= singular_name %> = <%= model_name %>.find(params[:id]) end def update - @<%= singular_name %> = <%= model_name %>.find(@params[:id]) - if @<%= singular_name %>.update_attributes(@params[:<%= singular_name %>]) - flash['notice'] = '<%= model_name %> was successfully updated.' + @<%= singular_name %> = <%= model_name %>.find(params[:id]) + if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>]) + flash[:notice] = '<%= model_name %> was successfully updated.' redirect_to :action => 'show<%= suffix %>', :id => @<%= singular_name %> else - render_action 'edit<%= suffix %>' + render :action => 'edit<%= suffix %>' end end def destroy<%= suffix %> - <%= model_name %>.find(@params[:id]).destroy + <%= model_name %>.find(params[:id]).destroy redirect_to :action => 'list<%= suffix %>' end end diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml b/railties/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml index 4fb704219a..3e969b9ac4 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml @@ -5,6 +5,8 @@ </head> <body> +<p style="color: green"><%%= flash[:notice] %></p> + <%%= @content_for_layout %> </body> diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml b/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml index 4caf1d06a0..0e92acb103 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml @@ -1,8 +1,8 @@ <h1>Editing <%= singular_name %></h1> <%%= start_form_tag :action => 'update<%= @suffix %>', :id => @<%= singular_name %> %> - <%%= render_partial "form" %> - <%%= submit_tag "Edit" %> + <%%= render_partial 'form' %> + <%%= submit_tag 'Edit' %> <%%= end_form_tag %> <%%= link_to 'Show', :action => 'show<%= suffix %>', :id => @<%= singular_name %> %> | diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml b/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml index f30772b41b..566c6bad1d 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml @@ -2,9 +2,9 @@ <table> <tr> -<%% for column in <%= model_name %>.content_columns %> + <%% for column in <%= model_name %>.content_columns %> <th><%%= column.human_name %></th> -<%% end %> + <%% end %> </tr> <%% for <%= singular_name %> in @<%= plural_name %> %> @@ -14,13 +14,13 @@ <%% end %> <td><%%= link_to 'Show', :action => 'show<%= suffix %>', :id => <%= singular_name %> %></td> <td><%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => <%= singular_name %> %></td> - <td><%%= link_to 'Destroy', {:action => 'destroy<%= suffix %>', :id => <%= singular_name %>}, :confirm => "Are you sure?" %></td> + <td><%%= link_to 'Destroy', {:action => 'destroy<%= suffix %>', :id => <%= singular_name %>}, :confirm => 'Are you sure?' %></td> </tr> <%% end %> </table> -<%%= link_to "Previous page", { :page => @<%= singular_name %>_pages.current.previous } if @<%= singular_name %>_pages.current.previous %> -<%%= link_to "Next page", { :page => @<%= singular_name %>_pages.current.next } if @<%= singular_name %>_pages.current.next %> +<%%= link_to 'Previous page', { :page => @<%= singular_name %>_pages.current.previous } if @<%= singular_name %>_pages.current.previous %> +<%%= link_to 'Next page', { :page => @<%= singular_name %>_pages.current.next } if @<%= singular_name %>_pages.current.next %> <br /> diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml b/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml index 3521b00536..8db70cd89d 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml @@ -1,7 +1,7 @@ <h1>New <%= singular_name %></h1> <%%= start_form_tag :action => 'create<%= @suffix %>' %> - <%%= render_partial "form" %> + <%%= render_partial 'form' %> <%%= submit_tag "Create" %> <%%= end_form_tag %> |