Ruby on Rails
Monday, November 23, 2015
after defining wihtout_parent in the model i reloaded the page and got this error for line 2 of index.html.erb
On Saturday, November 21, 2015 at 4:44:02 PM UTC-5, Colin Law wrote:
-- <%= render @parent_categories %>
error:
'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path.
was <%= render @parent_categories %> supposed to call the _category.html.erb partial ?
On Saturday, November 21, 2015 at 4:44:02 PM UTC-5, Colin Law wrote:
On 21 November 2015 at 18:50, fugee ohu <fuge...@gmail.com> wrote:i'm trying to follow these instructions:
in my categories_controller.rb
def index @parent_categories = Category.without_parents
in my index.html.erb
<ul> <%= render @parent_categories %> </ul>
in my _categories.html.erb
<ul> <li> <strong><%= category.name %></strong> <ul> <%= render category.categories %> </ul> </li> </ul>
but this doesn't work i get unknown method wihtout_parents and couldn't figure out what without_parents was supposed to be so, i tried changing the line in the controller to @parent_categories = Category.where("parent_id=0") and it was on to the next error, now i getundefined method `categories' for #<Category:0xb1604e2c> My understanding is that in the statement, category is the partial view and categories means the entire collection, so then why doesn't rails recognize the meaning of categories as the entire collection and what's the story with "without_parents" ? ~ thanks, fugeeI am afraid your ideas are so horribly mixed up it is difficult to know where to start. I think the instructions you are following must be rather poor. I suggest instead you start by working right through railstutorial.org (which is free to use online) which will show you the basics of Rails in a way which most can follow.Colin
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6d0e7547-0a48-4823-8636-0d96ac8b53fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment