2
\$\begingroup\$

In the _form partial I have a rather complicated logic which builds necessary options for input fields:

- input_html_params = dynamic_settings_select_options('#service-settings', settings_aps_instance_services_path(parent))
= simple_form_for [:aps, parent, resource] do |f|
 = f.input :service_status, :as => :readonly_label 
 = f.input :meta_service_meta_id, :collection => parent.meta_services, :value_method => :meta_id, :label_method => :name, :input_html => input_html_params
 = f.button :submit

The first problem which I see here is getting input_html_params to pass them into input of meta_service_meta_id because it already has a lot of parameters. Even this didn't help us to avoid long string to pass all parameters. What is best practice to avoid this complicity?

As you can see, extracting them to helper methods doesn't solve this problem, so I would like to hear something new.

Jamal
35.2k13 gold badges134 silver badges238 bronze badges
asked Oct 19, 2013 at 9:00
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

You should be able to use a Simple Form Custom Input.

As I don't know Simple Form well enough, I don't know if you can access the routes from a custom input class.

If not, see the answers to these questions:

and

answered Nov 12, 2013 at 15:26
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.