How do you handle single table inheritance in SimpleForm, so one helper handles all models?

We have an "EventSession" model, which has several subtypes via STI, including "NetworkingEventSession" and "DiningEventSession" ... we want to be able to process all of them from one controller and one view in some cases, but just the form looks at objects when repeating through simple_form_for @session and trying to use the helper helper network_event_session_path, which we currently do not define, instead of the usual path event_session_helper, which will work just fine and what we want.

I could define new routes to get helpers for each subtype, all directing to the same path, but it will be very unDRY, and we do not always want them to go to the main path of the event session ... is there any is there a way to override simple_form_for in this particular view to explicitly indicate which model / class to use?

+3
source share
1 answer

Indicate :url=> networking_event_session_pathin simple_form_for.

Something like that:

<%= simple_form_form @session, :url => networking_event_session_path %>
+3
source

All Articles