0

How do I call a helper inside an engine from the Rails console? I tried

app.coverart
app.refinery.coverart
helper.coverart
helper.refinery.coverart
Refinery::Books::Engine.helpers.coverart
Refinery::Books::Engine.app.coverart
Refinery::Books::Engine.app.helper.coverart

They all say NoMethodError: undefined method.

Rails version 3.2.14.

Chloe
  • 25,162
  • 40
  • 190
  • 357

1 Answers1

2

If you want to include functions from Refinery::Books::ApplicationHelper you can do this like the following.

irb(main):001:0> include Refinery::Books::ApplicationHelper
irb(main):002:0> respond_to? :function_from_engine_helper
=> true
ole
  • 5,166
  • 5
  • 29
  • 57
  • Thanks! Had to use `include Refinery::Books::BooksHelper`. Foiled by `asset_path` in the method though! – Chloe May 05 '14 at 22:18
  • Not exactly understand what do you mean, but if you need `asset_path` helper in the console, you can't include this, but you can delegate like this: `def asset_path(*args);ActionController::Base.helpers.asset_path(*args);end` – ole May 05 '14 at 22:26