overiding to_param of a nested attribute
- by cbrulak
I'm trying to create a perma link for a nested attribute.
For example, look at the links for the answers in SO. I would like to do something similar in rails:
I have Project model with multiple tasks and I would like to create a perma link to a task.
The task can only viewed with the project, just like Q & A on SO.
Ideally, i would do something like:
task_helper.rb:
def GetTaskURL
project = Project.find(:project_id)
return project_url(project,:html) + "#" + id
end
However, i get a method not found. So it seems the only way is to hard-code it:
domain.com url + Projects/show/id.html#task.id
Must be a better way?