[PhillyOnRails] Calling a helper based on dynamically created string

Mike Zornek mikezornek at mikezornek.com
Thu Mar 1 21:26:02 MST 2007


You know how when you are using the new resource features in Rails 1.2 it
will create all these helper methods for you. Like if I had a resource for
my `Comment` class I'd get `comments_url`, `comments_path`,
`comment_path(1)`, etc. Well let's say I'm trying to dry up my views -- some
of these crud pages are just very repetitive -- how do I call a helper based
on a string I create. I'd like to create a string like
`object.class.to_s.downcase.pluralize + '_url' and then call that helper.
How can I do this?

~ Mike
-- 
Work: http://ClickableBliss.com
Play: http://MikeZornek.com




More information about the talk mailing list