Skip to content
Browse files

Updated with the latest tricks

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6747 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 056fdc7 commit 40486288efea032808901a39787058f0d456cf16 @dhh dhh committed May 16, 2007
View
6 railties/lib/rails_generator/generators/components/scaffold/USAGE
@@ -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
4 ...s/scaffold/scaffold_resource_generator.rb → ...components/scaffold/scaffold_generator.rb
@@ -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 @@ def manifest
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
6 railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
@@ -45,7 +45,7 @@ def create
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 @@ def update
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 @@ def destroy
@<%= 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
2 railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb
@@ -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>

0 comments on commit 4048628

Please sign in to comment.
Something went wrong with that request. Please try again.