问题描述
我在rails 6应用程序中使用了best_in_place gem。
使用display_with
选项显示自定义文本时遇到困难
%tbody
- @users.each do |user|
%tr
%td.center
= best_in_place user,:month,:as => :select,:display_with => lambda { |index| format_month(index) },:collection => { '1' => 'Jan','2' => 'Feb','3' => 'Mar' }
我在application_helper.rb
中有此方法
def format_month(index)
case index
when '1'
'January'
when '2'
'February'
when '3'
'march'
end
end
我已经检查了值(1,2,3 ...)正在保存在数据库中,还正在调用format_month
方法(通过放置byebug
检查)。
我想在用户界面上显示完整的月份名称,即一月,二月,三月...但是它显示的是收集中提到的选项中的一月,二月,三月。
我不确定我在做什么错。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)