small medium large xlarge

Generic-user-small
19 Aug 2008, 13:37
Sultan Bhatia (7 posts)

I am on Win XP and use Aptana Studio for RoR

Ever since I started using RAILS 2.x, the “generate scaffold” function does not generate the complete views, the column information is missing.

“edit.html.erb”:

Editing product

<% form_for(@product) do |f| %> <%= f.error_messages %>

<%= f.submit “Update” %>

<% end %>

<%= link_to ‘Show’, @product %> | <%= link_to ‘Back’, products_path %>

“index.html.erb”:

Listing products

<% for product in @products %> <%= link_to 'Show', product %> <%= link_to 'Edit', edit_product_path(product) %> <%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %> <% end %>


<%= link_to ‘New product’, new_product_path %>

“new.html.erb”:

New product

<% form_for(@product) do |f| %> <%= f.error_messages %>

<%= f.submit “Create” %>

<% end %>

<%= link_to ‘Back’, products_path %>

“show.html.erb”:

<%= link_to ‘Edit’, edit_product_path(@product) %> | <%= link_to ‘Back’, products_path %>

The partial _form.html.erb is not generated.

I am wondering if this is how RAILS 2.x works, or is this specific to Aptana, or am I missing some option?

Samr_small_pragsmall
19 Aug 2008, 14:22
Sam Ruby (634 posts)

The generate scaffold function in Rails 2.x is fundamentally different than the same-named function in Rails 1.x.

In Rails 1.x, generate scaffold did not have additional parameters, and generated dynamic views that queried the model and produced a minimal, but fully functional, view. This was great demo-ware, but did not provide an effective starting point for people to modify. Generally, it required code that was incomprehensible to novices to be ripped out and be replaced with new code.

In Rails 2.x, generate scaffold has additional parameters which allows you to define your initial model using any number of name:type pairs. Static scaffolding is generated for these columns/attributes only. This provides a much better starting point for modification.

This is covered in sections 6.2 and 6.3, and in particular in the “David says…” box on page 82.

Generic-user-small
19 Aug 2008, 14:59
Sultan Bhatia (7 posts)

Thanks for the explanation. It makes sense now.

You must be logged in to comment