开发者

User helper functions in Lib classes

开发者 https://www.devze.com 2023-02-14 18:19 出处:网络
In rails 3, is it possible to use helper functions in library classes? for example, I have helper: module CarHelper

In rails 3, is it possible to use helper functions in library classes? for example, I have helper:

module CarHelper
  def total_price(cars)
    #Do something here
  end
end

In my Lib/my_library.rb

class MyLibrary
 def myFunc
   # I would like to use helper function total_price(cars) here
 end
开发者_如何学C

end

How to use helper functions in Lib classes?


include CarHelper in your MyLibrary class should do the job .

0

精彩评论

暂无评论...
验证码 换一张
取 消