I have some issues with a controller in my rails3 application that is called nas
My ruby app is connected to an existing DB so the table name has to stay as nas.
In my models, I have previously been able to do this:
set_table_name
But I don't know how to do this in my controller / routes.
Right now, my routes contains this:
resources :nas
And the output is:
new_na GET /nas/new(.:format) {:action=>"new", :controller=>"nas"}
edit_na GET /nas/:id/edit(.:format) {:action=>"edit", :controller=>"nas"}
na GET /nas/:id(.:format) {:action=>"show", :controller=>"nas"}
PUT /nas/:id(.:format) {:action=>"update", :controller=>"nas"}
DELETE /nas/:id(.:format) {:action=>"destroy", :controller=>"nas"}
As you can see, rails drops the 's'
How can I resolve this?
Thanks
It's pretty confusing because I have no idea what a "na" or "nas" is. From your question I have the idea that you always want to refer to it as "nas", both plural and singular.
If that's the case, then the answer is to put this in config/initializers/inflections.rb
:
ActiveSupport::Inflector.inflections do |inflect|
inflect.uncountable "nas"
end
This will also make your Nas
model use the nas
table by default, so no need for set_table_name
.
However note that there is no reason to use Nas
for your controllers if you don't want to! You can name them anything you like, as long as this is reflected in routes.rb
and you use the correct model in your controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With