undefined method `content_for' in presenter rails

后端 未结 1 613
一整个雨季
一整个雨季 2021-01-23 14:51

I am using a presenter for a view in rails to display data which is saved in a yml file. (i18n gem)

This is the controller-

class DocumentsController <         


        
相关标签:
1条回答
  • 2021-01-23 15:23

    the content_for helper method should not be used in your model as this violates the MVC pattern.

    if you must use it, though this is not reccomended, you can add this at the bottom of your model.

    def helpers 
        ActionController::Base.helpers
    end
    

    Then to call content_for you would use

    class DocumentPresenter
      def viewname
          helpers.content_for :secondary_nav_title do
             t('Documents')
          end
      end
    end
    
    0 讨论(0)
提交回复
热议问题