#1 ✓resolved
Brian Pokosh

extending object_path for custom controller actions

Reported by Brian Pokosh | April 23rd, 2009 @ 10:14 PM

I use object_path religiously in my views because I have two different sets of routes. In this example, object_path resolves to either: admin_videos_path

or

account_video_path

For this controller I'd like to make a slight deviation from restful conventions and have a convert action in the controller. I'd like to be able to use the path object_path(object, :action => :convert) or something similar.

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson April 23rd, 2009 @ 10:16 PM

    • State changed from “new” to “open”

    I know this is a long shot, but did you try the above?

  • Brian Pokosh

    Brian Pokosh April 23rd, 2009 @ 10:24 PM

    I did. I like to assume that things will just work the why I want them to.

  • Ben Johnson

    Ben Johnson April 23rd, 2009 @ 10:26 PM

    Right, but did it work? I'm assuming it didn't, but I figured I would ask.

  • Brian Pokosh

    Brian Pokosh April 23rd, 2009 @ 10:37 PM

    It didn't work.

    I get a "ccount_video_url failed to generate from ..." error.

  • Ben Johnson

    Ben Johnson April 23rd, 2009 @ 10:43 PM

    Ok, I'm on the fence here. I'm kind of inclined to do some method_missing magic so that you can do:

    edit_object_url
    new_object_url
    whatever_object_url
    whatever_new_object_url
    whatever_collection_url
    

    It kind of fits in better with the existing edit action. The alternative is to do something like:

    object_url(:action => :whatever)
    

    Like you described above. What do you think?

  • Brian Pokosh

    Brian Pokosh April 23rd, 2009 @ 10:52 PM

    I tried convert_object_path(object) before I tried object_path(object, :action => :convert)

    I really didn't expect either to work but that was the order they popped into my mind, if that means anything.

    But I haven't really looked at any of the resourcelogic code to know what kind of downfalls messing with method_missing might have.

  • Ben Johnson

    Ben Johnson April 24th, 2009 @ 08:49 PM

    • State changed from “open” to “resolved”

    This has been implemented, update from the repo. Thanks for letting me know about this. I really feel like the library is coming a long well and has remained simple. Let me know if you ahve any feature suggestions, etc.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Adds context into the RESTful development style.

People watching this ticket

Pages