Updated with the latest tricks

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6747 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2007-05-16 01:31:32 +00:00
parent 056fdc74d5
commit 40486288ef
4 changed files with 9 additions and 9 deletions

View File

@@ -32,6 +32,6 @@ Description:
making your new resource accessible from /posts.
Examples:
./script/generate scaffold_resource post # no attributes, view will be anemic
./script/generate scaffold_resource post title:string created_on:date body:text published:boolean
./script/generate scaffold_resource purchase order_id:integer created_at:datetime amount:decimal
./script/generate scaffold post # no attributes, view will be anemic
./script/generate scaffold post title:string created_on:date body:text published:boolean
./script/generate scaffold purchase order_id:integer created_at:datetime amount:decimal

View File

@@ -1,4 +1,4 @@
class ScaffoldResourceGenerator < Rails::Generator::NamedBase
class ScaffoldGenerator < Rails::Generator::NamedBase
attr_reader :controller_name,
:controller_class_path,
:controller_file_path,
@@ -79,7 +79,7 @@ class ScaffoldResourceGenerator < Rails::Generator::NamedBase
protected
# Override with your own usage banner.
def banner
"Usage: #{$0} scaffold_resource ModelName [field:type, field:type]"
"Usage: #{$0} scaffold ModelName [field:type, field:type]"
end
def scaffold_views

View File

@@ -45,7 +45,7 @@ class <%= controller_class_name %>Controller < ApplicationController
respond_to do |format|
if @<%= file_name %>.save
flash[:notice] = '<%= class_name %> was successfully created.'
format.html { redirect_to <%= file_name %>_url(@<%= file_name %>) }
format.html { redirect_to(@<%= file_name %>)
format.xml { render :xml => @<%= file_name %>, :status => :created, :location => <%= file_name %>_url(@<%= file_name %>) }
else
format.html { render :action => "new" }
@@ -62,7 +62,7 @@ class <%= controller_class_name %>Controller < ApplicationController
respond_to do |format|
if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
flash[:notice] = '<%= class_name %> was successfully updated.'
format.html { redirect_to <%= file_name %>_url(@<%= file_name %>) }
format.html { redirect_to(@<%= file_name %>) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
@@ -78,7 +78,7 @@ class <%= controller_class_name %>Controller < ApplicationController
@<%= file_name %>.destroy
respond_to do |format|
format.html { redirect_to <%= table_name %>_url }
format.html { redirect_to(<%= table_name %>_url) }
format.xml { head :ok }
end
end

View File

@@ -14,7 +14,7 @@
<% end -%>
<td><%%= link_to 'Show', <%= singular_name %> %></td>
<td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
<td><%%= link_to 'Destroy', <%= singular_name %>), :confirm => 'Are you sure?', :method => :delete %></td>
<td><%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<%% end %>
</table>