0

我是 Rails 的新手,我很难理解为什么我的帮助模块在从 ActionMailer 调用时不起作用。我从不同的部分调用相同的方法,它工作正常。问题不在于方法,而在于我的会话变量 (session[:geo]) - 它说“未定义的方法‘会话’”。

这是我的代码任何建议都非常感谢

products_helper.rb

def isUserLocal?
    session[:geo] #true or false
end

def itemTotalPrice(item)
    if self.isUserLocal?
        item.line_item_us_total_price
    else
        item.line_item_w_total_price
    end
end

订单通知器 - ActionMailer

   class OrderNotifier < ActionMailer::Base

   helper :Products #helpers are not available in ActionMailers by default

收到的.html.erb

   <%= render @order.line_items -%>

_line_items.html.erb

   number_to_currency(itemTotalPrice(line_item))
4

0 回答 0