Acces to restfull route paths in models

You are not allowed to access controller-related stuff in the models. It violates MVC. You will find that you can’t access sessions, request parameters, or other things back there.

You may want to use your models without using your controllers, like for backend stuff. You might need a whole new controller layer at some point, instead of the HTML-based one (like flex maybe, so restful routing isn’t an issue.

I recommend making a helper that takes the model as a parameter.

If there’s a specific reason you need to have that information in there, you can hack around it by including the appropriate modules in your model class. A purist would find this ugly… if you’re hitting a wall with MVC, it might be because you’re trying to do something you shouldn’t. (That’s not always true… there are valid reasons for violating MVC, but they are rare.)

Maybe you could explain in more detail the feature you’re trying to implement, and someone could come up with an alternative solution for you.

Good luck!

No, you’re on the right track…

helper method should work fine. In your view, you’d do this:

<%=link_to “back”, parent_link_url(@componentgroup) %>

determines the parent link.

def parent_link_url(component) component.root == component ? pageresources_path component : groupresources_path self.parent end

Let me know if that’s gonna work for you.