views:

174

answers:

1

Hi,

I have the following routes:

resources :categories do
  resources :articles
end

And the following views:

# edit.erb and new.erb files:
<%= render :partial => 'form' %>

# top of _form.html.erb file:
<%= form_for category_article_path(@article.category, @article) do |f| %>

But I have some troubles with the given path. I work with Rails 3. Here is an example of error that I get when testing:

undefined method `category' for nil:NilClass

What is the basic way to write a such path? Many thanks.

A: 

Just pass a freshly newed up article (with an existing category) instance to the view.

Jan Limpens