# Strange error.... ActionController::RoutingError

**URL:** <https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872>\
**Category:** Rails\
**Created:** [January 13, 2008, 5:37am UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872 "2008-01-13T05:37:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [January 13, 2008, 5:37am UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872/1 "2008-01-13T05:37:11Z")

</div>

Hello, i have a problem, had a table called news and other called  
news\_images,  
the first é for save news and other for save url for images associated  
with news.  
Make migrations for each table manual and db:migrate after that i run  
scaffold for news, and generate model for news\_image… put has\_many  
and belongs\_to in file\_column on news\_image model and ok… when i  
try access page for new News i get this error:

ActionController::RoutingError in News#new  
news\_url failed to generate from  
{:action=\>“show”, :controller=\>“news”} - you may have ambiguous  
routes, or you may need to supply additional parameters for this  
route. content\_url has the following required parameters:  
[“news”, :id] - are they all satisfied?

Extracted source (around line #5):

2:  
3: \<%= error\_messages\_for :news %\>  
4:  
5: \<% form\_for(@news) do |f| %\>

I don’t understand why, i don’t had any other route with same name in  
routes.rb, i can’t had tables with names like news?

Obrigado .

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [January 13, 2008, 6:41pm UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872/2 "2008-01-13T18:41:32Z")

</div>

Some one can help?

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [January 13, 2008, 9:08pm UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872/3 "2008-01-13T21:08:31Z")

</div>

Understand Jean, thanks.

On Jan 13, 3:51 pm, “Jean-François Trân” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [January 13, 2008, 6:52pm UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872/4 "2008-01-13T18:52:46Z")

</div>

Daniel L. :

> news\_url failed to generate from  
> {:action=\>“show”, :controller=\>“news”} - you may have ambiguous  
> routes, or you may need to supply additional parameters for this  
> route. content\_url has the following required parameters:  
> [“news”, :id] - are they all satisfied?

The word news is uncountable, so you have to specify a  
:singular option with map.resources.

see :  
[http://somethinglearned.com/articles/2007/03/19/how-to-uncountable-names-in-restful-routes](http://somethinglearned.com/articles/2007/03/19/how-to-uncountable-names-in-restful-routes)

```
-- Jean-François.

```

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [January 20, 2008, 11:58pm UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872/5 "2008-01-20T23:58:01Z")

</div>

You aren’t defining @news in your edit method definition in your news  
controller

On Jan 20, 2008 9:05 PM, Bregor [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 9: \<% form\_for(@news) do |f| %\>  
> All other are works, except edit…
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [January 20, 2008, 11:36am UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872/6 "2008-01-20T11:36:33Z")

</div>

Hello all!

I still don’t understand, what to do in news/edit.html.erb

when I try to get /news/1/edit (news with this id exists, of course) i  
see following:

NoMethodError in News#edit

Showing news/edit.html.erb where line #9 raised:

You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.to\_sym

Extracted source (around line #9):

6:

  
7: \<%= error\_messages\_for :news %\>  
8: 
  
9: \<% form\_for(@news) do |f| %\>

link to edit looks like: \<%= link\_to ‘Edit’,  
edit\_news\_instance\_path(news), :class=\>“button long” %\>

In routes.rb:

map.resources :news, :singular =\> ‘news\_instance’

All other are works, except edit…

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [January 23, 2008, 9:49am UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872/7 "2008-01-23T09:49:52Z")

</div>

Actually the problem is not that @news is not defined in the edit  
action  
(it might be an additional problem)

The way I see it, he :singular option is only used to create  
the the url-generation methods for the resource (e.g.  
edit\_news\_instance\_path, etc.)

This option however is not used by the form\_for @news call to deduct  
the name  
of the url-generation-method. It just gets the singular class name of  
the News class  
from the inflections, hence instead of edit\_news\_instance\_path,  
edit\_news\_path  
is called, which, of course, does not exist.

A workaround might be specifying the :url option in form\_for, although  
I’ve had  
trouble with this, too, at least when using namespaced resources.

I hope this helps

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [May 22, 2008, 1:37am UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872/8 "2008-05-22T01:37:58Z")

</div>

Daniel L. wrote:

> Hello, i have a problem…

In file:  
your\_app\_name\config\initializers\inflections.rb  
add string: inflect.uncountable %w( news )  
and read comments

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [May 22, 2008, 1:41am UTC](https://www.ruby-forum.com/t/strange-error-actioncontroller-routingerror/125872/9 "2008-05-22T01:41:23Z")

</div>

me wrote:

> In file:  
> your\_app\_name\config\initializers\inflections.rb  
> add string: inflect.uncountable %w( news )  
> and read comments  
> My appologies, add :

Inflector.inflections do |inflect|  
inflect.uncountable %w( news )  
end
