0

After getting rid of this question, I get one another.

I have a path method specified in routes resources :tree_nurseries do .... And shows correctly when I do rake routes which gives new_tree_nursery then normally new_tree_nursery_path will be available.

But, when I call it with a link_to method, it remains undefiend.... (new_tree_nursery_path)

What did I missed again?

this is the code line :

.actions
  = link_to t('.new', :default => t("helpers.links.new")), new_tree_nursery_path, :class => 'btn btn-primary pull-right'

And the rake routes result :

               tree_nurseries GET    /tree_nurseries(.:format)                     tree_nurseries#index
                          POST   /tree_nurseries(.:format)                     tree_nurseries#create
         new_tree_nursery GET    /tree_nurseries/new(.:format)                 tree_nurseries#new
        edit_tree_nursery GET    /tree_nurseries/:id/edit(.:format)            tree_nurseries#edit
             tree_nursery GET    /tree_nurseries/:id(.:format)                 tree_nurseries#show
                          PUT    /tree_nurseries/:id(.:format)                 tree_nurseries#update
                          DELETE /tree_nurseries/:id(.:format)                 tree_nurseries#destroy

config/environment.rb :

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'tree_nursery', 'tree_nurseries'
end
Community
  • 1
  • 1
jramby
  • 426
  • 5
  • 14
  • We would need to see the relevant lines of code exactly as they appear in your file. It could be as simple as a typo. For example, did you mean `resources :tree_nurseries` with a colon? – Austin Mullins Feb 03 '13 at 16:30
  • Yes, `resources :tree_nurseries` with a colon, because it shows the right paths with `rake routes` command, But returns undefined method `new_tree_nursery_path` when calling it in views. – jramby Feb 03 '13 at 16:52
  • What's the actual line where this function is called? You can edit the original question to include the relevant lines of code. For example, it should be like `<%= link_to "New Tree Nursery", new_tree_nursery_path %>`. Also, what's the actual line from the `rake routes` output? – Austin Mullins Feb 03 '13 at 16:55
  • thank you for your time, I've added the required lines of codes... don't forget to look at the [previous question](http://stackoverflow.com/questions/14673532/rails-cant-map-automatically-y-ending-plural-models-is-it-possible)... maybe there is an important element tha t you shouldn't miss – jramby Feb 03 '13 at 17:11
  • Thanks. I'm as stumped as you are right now. I did see your last question about inflections, and it's pretty clear from the rake routes output that things are inflicting correctly. Now I'm wondering about the function t() in your link_to. It's probably not the issue, I'm just curious. – Austin Mullins Feb 03 '13 at 17:55
  • Or maybe I was wrong on the manner I've added in `config/environment.rb` the last lines in my last post edit. – jramby Feb 03 '13 at 18:11
  • **Next thing I've tried :** I've changed the method call **`new_tree_nurseries_path`** instead of the one before...And that's it... the error was gone.. allthough, the rake routes invoke result is always the same as before `new_tree_nursery` – jramby Feb 03 '13 at 18:21
  • Inflection seems ok. The route exists. I think someone more experienced will need to look at this. – Austin Mullins Feb 03 '13 at 18:21

0 Answers0