P
P
prostoy_chelovek2020-12-05 02:39:53
Ruby on Rails
prostoy_chelovek, 2020-12-05 02:39:53

How to set a condition for a specific field in the select pop-up list in the view in ruby ​​on rails?

Help, please, with one problem. I have a popup list, but I need to make 2 conditions for one of the fields. Essentially throw this check_box condition

- if policy(@callcenter).activate_trial?
  = f.check_box :trial_mode, disabled: [email protected]_mode_allowed, custom: :switch

on the trail field I have in enum status(enum status: [:active, :trial, :suspended, :blocked])

= f.select :status, t_enum_for_select(Callcenter, :statuses)


And one more thing, one of the fields needs to be made unavailable for selection, but it should be displayed in the list, because it comes via api from another application and is installed in it automatically

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
prostoy_chelovek, 2020-12-09
@prostoy_chelovek

Still managed to solve the problem

= f.select :account_status, t_enum_for_select(Callcenter, :account_statuses),
                                      disabled: ['suspended', ('trial' if [email protected]_mode_allowed || policy(@callcenter).activate_trial?)]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question