0

I know it's not advised to go more then 1 level deep in nested routes but here's what I have:

  resources :partners do
    resources :recommend_partners do
      resources :rec_partner_comments
    end
  end

Is there a way that I can call an alias to use the name_route

So instead of using

new_partner_recommend_partner_rec_partner_comments

I'll use something like

new_comment_on_pr

Just a thought...

Breno
  • 5,952
  • 1
  • 20
  • 25

1 Answers1

0

You can always create a helper function

def new_comment_on_pr(*args)
  new_partner_recommend_partner_rec_partner_comments(*args)
end

Also do you know of a more clear route path syntax in Rails? Instead of

partner_recommend_partner_rec_partner_comments(partner, recommend_partner)

you can write

[partner, recomment_partner, :comments]
binarycode
  • 1,788
  • 15
  • 15
  • `[partner, recomment_partner, :comments]` will get me the index! The helper function works for my other routes but I don't know why it isn't working for this one.. if I use: `new_partner_recommend_partner_rec_partner_comment` in the show, or a helper function it still gives me the same error: undefined method `new_partner_recommend_partner_rec_partner_comment' – Breno Jun 29 '12 at 02:47
  • And, as an extra information, I got that route from the rake routes in the console, so it shouldn't render and error... at least not an undefined method error... – Breno Jun 29 '12 at 02:49
  • The example i gave you will give you the index indeed. To get the path you want it should look like `[:new, partner, recommend_partner, :rec_partner_comment]`. Anyway if the `rake routes` displays this path then the helper should be available. I notice that your example contains `new_partner_recommend_partner_rec_partner_comments` instead of `new_partner_recommend_partner_rec_partner_comment` (notice the S at the end). Maybe this is the reason? – binarycode Jun 29 '12 at 04:45
  • Nope, I just wrote it wrong the first time, it's without the S at the end... But the [:new, partner, recommend_partner, :rec_partner_comment] works!!! I'm just confused why the route shown in my rake routes gives me and undefined method error.. because I litterly copied from the console and pasted so I now it's exactly the same... – Breno Jun 29 '12 at 21:47