Hello friends!
What is the current state of the art when trying to construct nice nested
URLs? Don't know what I mean? Check out these bad boys:
github.com/chrislloyd
github.com/chrislloyd/brains
Say I was building Github (I'm not!), I'd really just like to link_to @repo
rather
than every time having to specify link_to [@repo.owner, @repo]. That's not
too much to ask is it?
I started down the road of using to param in the model:
def to_param
[owner, slug].to_param
end
But that didn't end up working as I'd basically have to write my own catch
all router in my app (as /user and /user/repo would be covered by the same
route). I then tried overriding the default path helpers:
def repo_path(repo)
super(repo.owner, repo)
end
However this has quickly turned into a cluster-cussin' mess as I have to
make new helpers for each nested route. Is there some Rails-ey way of doing
something like this? It seems like a common enough problem that somebody far
smarter than me has already thought up a solution.
Cheers!
Chris
--
You received this message because you are subscribed to the Google Groups "Ruby
or Rails Oceania" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rails-oceania/-/scv4S6wVHyEJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.