我想做:
如果Seller.accounting_acc则为“所有状态都可能”,如果卖方没有account_access,则为“除销售/在手状态以外的所有状态”
这是我的代码:
<% if current_user.seller? && current_user.accounting_access? %>
<%= select_tag :set_state, options_for_select(state_options_for_seller, "comment"), class: "form-control set_state", id: "prospect_form_set_state" %>
<% else %>
<%= select_tag :set_state, options_for_select(state_options_for_seller, "comment", disabled: "sale"), id: "prospect_form_set_state" %>
<% end %>
我陷入了这个问题。
答案 0 :(得分:0)
查看:
<%= select_tag :set_state, options_for_select(state_options_for_seller(current_user), "comment"), class: "form-control set_state", id: "prospect_form_set_state" %>
方法(在状态模型中?),元代码,当然不知道确切的字段名称,所以请适应您的情况。
def state_options_for_seller(current_user)
if current_user.seller? && current_user.accounting_access?
return State.all
else
return State.where.not(state: 'sale')
end
end