-- category.rb
class Category < ActiveRecord::Base
has_many :subcategories
validates_presence_of :name
validates_uniqueness_of :name
end
-- subcategory.rb
class Subcategory < ActiveRecord::Base
belongs_to :category
end
-- categories_controller.rb
def show
@category = Category.find_by_id(params[:id])
respond_with @category
end
-- routes.rb
resources :categories do
resources :subcategories
end
-- categories/show.html.erb
<div style="padding: 15px; background-color: #D8AEB5; width: 100%;">
<%= link_to "See all Categories", categories_path %>
<span style="float: right;">
<%= button_to "delete this Category", category_path(@category),
:confirm => "Are you sure?", :method => :delete %>
</span>
</div>
<h1>Category: <%= @category.name %></h1>
<div class="card">
<table id="sub_categories">
<tr>
<th>Sub Category Name</th>
<th> </th>
</tr>
<% @category.subcategories.each do |category| %>
<tr>
<td><%= category.name %></td>
<td> </td>
</tr>
<% end %>
</table>
</div>
<div id="default" style="background: none repeat scroll 0 0 #F9EDD8;
padding: 5px; width: 98%">
<%= link_to "Create a new Sub Category",
new_category_subcategory(@category) %>
</div>
Here is the error I am getting. I've tried recreating this resource,
re-doing the routes. Restarting mongrel.
undefined method `new_category_subcategory' for
#<#<Class:0x4a5ec34>:0x4a5d600>
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.