Rails console - use image_tag method

xpepermint picture xpepermint · Nov 4, 2010 · Viewed 11.1k times · Source

How can I execute a image_tag method in a Rails console

  1. Run the console $ rails c

  2. Load helpers

    include ActionView::Helpers

  3. Execute the command

    image_tag('test.png')

I got a strange error. alt text

Please help!

Answer

aNoble picture aNoble · Nov 4, 2010

Not sure why you're getting that error. It is strange.

But the Rails Console exposes the helper methods through the helper variable. So this should work:

helper.image_tag('test.png')