Permalink
Browse files

nested scaffold is working now

  • Loading branch information...
ashrafuzzaman committed Jun 8, 2012
1 parent 6c9c5db commit c7fbee6d3cf334848783460d2ec4aed3f660e568
@@ -19,14 +19,20 @@ def add_has_many
inject_into_class "app/models/#{pr.singular_table_name}.rb", pr.class_name, " has_many :#{plural_table_name}\n"
end
def add_in_routes
gsub_file 'config/routes.rb', Regexp.new("resources :#{plural_table_name}\n"), ''
gsub_file 'config/routes.rb', Regexp.new("resources :#{pr.plural_table_name}\n"), "resources :#{pr.plural_table_name} do\n end\n"
inject_into_file 'config/routes.rb', "\n resources :#{plural_table_name}\n", :after => "resources :#{pr.plural_table_name} do"
end
protected
def singular_path
"#{pr.singular_table_name}_#{singular_table_name}_path"
end
def index_path
"#{pr.singular_table_name}_#{singular_table_name}_path(@#{pr.singular_table_name})"
"#{pr.singular_table_name}_#{plural_table_name}_path(@#{pr.singular_table_name})"
end
def resource_path
@@ -17,9 +17,9 @@
<% attributes.each do |attribute| -%>
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
<% end -%>
<td><%%= link_to 'Show', <%= resource_path %> %></td>
<td><%%= link_to 'Show', [@<%= pr.singular_table_name %>, <%= singular_table_name %>] %></td>
<td><%%= link_to 'Edit', edit_<%= singular_path %>(@<%= pr.singular_table_name %>, <%= singular_table_name %>) %></td>
<td><%%= link_to 'Destroy', <%= singular_path %>(@<%= pr.singular_table_name %>) %>, confirm: 'Are you sure?', method: :delete %></td>
<td><%%= link_to 'Destroy', [@<%= pr.singular_table_name %>, <%= singular_table_name %>], confirm: 'Are you sure?', method: :delete %></td>
<%% end %>
</tbody>
</table>
@@ -8,5 +8,5 @@
<% end -%>
<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
<%%= link_to 'Back', <%= index_helper %>_path %>
<%%= link_to 'Edit', edit_<%= singular_path %>(@<%= pr.singular_table_name %>, @<%= singular_table_name %>) %> |
<%%= link_to 'Back', <%= index_path %> %>

0 comments on commit c7fbee6

Please sign in to comment.