# Strange routing error

**URL:** <https://www.ruby-forum.com/t/strange-routing-error/188242>\
**Category:** Rails\
**Created:** [May 8, 2010, 7:13am UTC](https://www.ruby-forum.com/t/strange-routing-error/188242 "2010-05-08T07:13:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![badnaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e36b37/32.png) [@badnaam](https://www.ruby-forum.com/u/badnaam)\
**Post date:** [May 8, 2010, 7:13am UTC](https://www.ruby-forum.com/t/strange-routing-error/188242/1 "2010-05-08T07:13:28Z")

</div>

I am trying to populate a select element based on the selection change  
in another select element, all this via ajax.

I created a custom action called getsubcat and added it to my  
routes.rb

map.resources :gcertsteps, :has\_many =\> [:merchants], :collection =\>  
{:getsubcat =\> :get}

my getsubcat action is pretty simple, it just returns a hash, does not  
even hit the db. For some reason the ajax call is actually calling  
the #show method not the getsubcat method and I get an error that  
says…can’t find \<model\_name\> with id=subcat!!

Why is the show action being called when I am specifically calling the  
getsubcat action?

\<%= f.input :category\_name, :as =\> :select, :collection =\>  
Gcertstep::CATEGORIES.keys %\>  
\<%= observe\_field :gcertstep\_category\_name, :url =\> {:action =\>  
“getsubcat”}, :method =\> :get, :frequency =\> 0.5, :with =\>  
“‘category\_name=’ + encodeURIComponent(value)” %\>

Baffling…any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![badnaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e36b37/32.png) [@badnaam](https://www.ruby-forum.com/u/badnaam)\
**Post date:** [May 8, 2010, 7:40am UTC](https://www.ruby-forum.com/t/strange-routing-error/188242/2 "2010-05-08T07:40:58Z")

</div>

Hi, can you post the whole routes.rb file content?

2010/5/8 badnaam [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
