1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fixed scaffolding to use the latest style

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1380 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-06-02 20:13:02 +00:00
parent 3162f386dc
commit 32c0e895bf
7 changed files with 24 additions and 20 deletions

View file

@ -59,6 +59,8 @@
</head>
<body>
<p style="color: green"><%= flash['notice'] %></p>
<%= @content_for_layout %>
</body>

View file

@ -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>

View file

@ -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

View file

@ -5,6 +5,8 @@
</head>
<body>
<p style="color: green"><%%= flash[:notice] %></p>
<%%= @content_for_layout %>
</body>

View file

@ -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 %> %> |

View file

@ -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 />

View file

@ -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 %>