Rails console - use image_tag method

前端 未结 2 1063
太阳男子
太阳男子 2021-02-08 09:39

How can I execute a image_tag method in a Rails console

  1. Run the console $ rails c

  2. Load helpers

    include ActionView::Helper

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-08 10:34

    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')
    

提交回复
热议问题