Photo-1 Photo-2 Photo-3 Photo-4 Photo-5 Photo-6



Full-time web developer. Part-time smart ass.

I'm Brent Collier.

After a year and a half as an engineer on Twitter's Trust & Safety team, I'm looking for my next gig. Contact me if you know of something interesting.


Using link_to in a controller *gasp*

Posted on 05/16/2011

Yeah, I know it kind of breaks the MVC pattern, but whatever. Its not something you'd want to do all the time, but in the rare instance that you'd like to generate an anchor tag from within a controller, try this:

ActionController.helpers.link_to("Click Me!", awesome_path)

Chances are, whatever you're doing could/should probably be moved into a helper method instead of doing it in the controller, but that's up to you.