-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Does "rake routes" show anything helpful? On May 26, 5:23 pm, Adam Leonard <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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>-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Mike wrote:> Does "rake routes" show anything helpful?It shows me that the route exists. new_admin_session GET /admins/sign_in {:controller=>"devise/sessions", :action=>"new"} admin_session POST /admins/sign_in {:controller=>"devise/sessions", :action=>"create"} destroy_admin_session GET /admins/sign_out {:controller=>"devise/sessions", :action=>"destroy"} GET /listings(.:format) {:action=>"index", :controller=>"listings"} listings POST /listings(.:format) {:action=>"create", :controller=>"listings"} new_listing GET /listings/new(.:format) {:action=>"new", :controller=>"listings"} GET /listings/:id(.:format) {:action=>"show", :controller=>"listings"} PUT /listings/:id(.:format) {:action=>"update", :controller=>"listings"} listing DELETE /listings/:id(.:format) {:action=>"destroy", :controller=>"listings"} edit_listing GET /listings/:id/edit(.:format) {:action=>"edit", :controller=>"listings"} GET /admins(.:format) {:action=>"index", :controller=>"admins"} admins POST /admins(.:format) {:action=>"create", :controller=>"admins"} new_admin GET /admins/new(.:format) {:action=>"new", :controller=>"admins"} GET /admins/:id(.:format) {:action=>"show", :controller=>"admins"} PUT /admins/:id(.:format) {:action=>"update", :controller=>"admins"} admin DELETE /admins/:id(.:format) {:action=>"destroy", :controller=>"admins"} edit_admin GET /admins/:id/edit(.:format) {:action=>"edit", :controller=>"admins"} GET /categories/:category_id/subcategories(.:format) {:action=>"index", :controller=>"subcategories"} category_subcategories POST /categories/:category_id/subcategories(.:format) {:action=>"create", :controller=>"subcategories"} new_category_subcategory GET /categories/:category_id/subcategories/new(.:format) {:action=>"new", :controller=>"subcategories"} GET /categories/:category_id/subcategories/:id(.:format) {:action=>"show", :controller=>"subcategories"} PUT /categories/:category_id/subcategories/:id(.:format) {:action=>"update", :controller=>"subcategories"} category_subcategory DELETE /categories/:category_id/subcategories/:id(.:format) {:action=>"destroy", :controller=>"subcategories"} edit_category_subcategory GET /categories/:category_id/subcategories/:id/edit(.:format) {:action=>"edit", :controller=>"subcategories"} GET /categories(.:format) {:action=>"index", :controller=>"categories"} categories POST /categories(.:format) {:action=>"create", :controller=>"categories"} new_category GET /categories/new(.:format) {:action=>"new", :controller=>"categories"} GET /categories/:id(.:format) {:action=>"show", :controller=>"categories"} PUT /categories/:id(.:format) {:action=>"update", :controller=>"categories"} category DELETE /categories/:id(.:format) {:action=>"destroy", :controller=>"categories"} edit_category GET /categories/:id/edit(.:format) {:action=>"edit", :controller=>"categories"} new_user_session GET /users/login {:controller=>"devise/sessions", :action=>"new"} user_session POST /users/login {:controller=>"devise/sessions", :action=>"create"} destroy_user_session GET /users/logout {:controller=>"devise/sessions", :action=>"destroy"} POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"} user_password PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"} new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"} edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"} POST /users(.:format) {:action=>"create", :controller=>"registrations"} PUT /users(.:format) {:action=>"update", :controller=>"registrations"} user_registration DELETE /users(.:format) {:action=>"destroy", :controller=>"registrations"} new_user_registration GET /users/register(.:format) {:action=>"new", :controller=>"registrations"} edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"registrations"} root / {:controller=>"home", :action=>"index"} about /about {:controller=>"home", :action=>"about"} profile /profile {:controller=>"user", :action=>"profile"} users_change_password /users/change_password {:controller=>"registrations", :action=>"change_password"} users_update_password /users/update_password {:controller=>"registrations", :action=>"update_password"} -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
genkiwow-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2010-May-28 01:49 UTC
Re: Rails 3 telling me route doesn''t exist
Dude, it''s new_category_subcategory_path(@category), you missed a "_path" -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
genkiwow-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Dude, it''s new_category_subcategory_path(@category), you missed a > "_path"Yeah I found out today, I feel really stupid :/ -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.