form_for syntax?

I have been using this namespaced form_for syntax with no problems:
  <% form_for [:admin, @products] do |f| %>

However, now that I am working with a model and controller called
"news" which has no differentiation between singular and plural...

  <% form_for [:admin, @news] do |f| %>

... I am getting this exception when running my tests:

ActionView::TemplateError: admin_news_url failed to generate from
{:controller=>"adminl/news", :action=>"show"} - you may have ambiguous
routes, or you may need to supply additional parameters for this
route. content_url has the following required parameters: ["admin",
"news", :id] - are they all satisfied?

Rake Routes is showing me that I can get news#index via
sitecontrol_news_index.

I just can't figure out the syntax to make it all work within the
admin namespacing context.

Thanks for the help.
Elliott

You might consider adding an inflection for news in your config/
initializers/inflections.rb. That will tell Rails that the plural of
news is news. There are examples in the Rails-generated file.

Hi --

I have been using this namespaced form_for syntax with no problems:
<% form_for [:admin, @products] do |f| %>

However, now that I am working with a model and controller called
"news" which has no differentiation between singular and plural...

<% form_for [:admin, @news] do |f| %>

... I am getting this exception when running my tests:

ActionView::TemplateError: admin_news_url failed to generate from
{:controller=>"adminl/news", :action=>"show"} - you may have ambiguous

Is that "adminl" a typo in your code, or just in the email?

routes, or you may need to supply additional parameters for this
route. content_url has the following required parameters: ["admin",
"news", :id] - are they all satisfied?

Rake Routes is showing me that I can get news#index via
sitecontrol_news_index.

I just can't figure out the syntax to make it all work within the
admin namespacing context.

I'm not sure exactly how you've got it set up, but starting at the
simplest case: if you have this in your routes.rb:

   map.namespace :admin do |a|
     a.resources :news
   end

and if @news is a News object, and you've got an admin/news
controller, you should be OK.

David

Hi --

Thanks for the input guys.

The "adminl" is a email typo only...

Here's a truncated version of my route config.

map.namespace :admin do | admin |
   admin.resources :news, :collection => {:sort => :post}
  end

My tests confirm that news_controller.rb#new is indeed sending out a
new @news object. And the directory/namespacing is correct for sure. I
have already built out several other namespaced resource stacks for
this app. Is there a more verbose syntax I can try in form_for that
may allow me to get closer to the metal on this one?

Thanks!

I figured it out. It was directly related to the form_for syntax. I
guess that when rails generates the alternative explicit index route.
In this case "admin_news_index" vs "admin_news" a more explicit syntax
is needed.

Instead of this:

<% form_for [:admin, @news] do |f| %>

I found this solved my problem:

<% form_for @news, :url => admin_news_index_path do |f| %>