简体   繁体   中英

How to include ActionView::Helpers in rails controller?

Following is my code.

class PropertyDetailsController < ApplicationController
  include ActionView::Helpers

  #Action methods.
end

But the above code is throwing following error when I try to run.

Module::DelegationError (ActionView::Helpers::ControllerHelper#action_name delegated to controller.action_name, but controller is nil: 

Any Suggestions.

UPDATE Is that true if we use params and session we cant include ActionView::Helpers

Reference: http://alphahydrae.com/2013/06/rails-3-rendering-views-outside-a-controller/

我相信您必须require 'action_view'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM