0

I have a form_for tag specified as = form_for [@driver,@driver_availability].This stores the entered data in the driver_availabilities model and calls the create method of the DriversController. Is it possible to make it call some method i define in a different controller but continue saving data in the driver_availabilities model as usual ?

Thank You

1 Answer 1

2

[@driver, @driver_availability] will call driver_driver_availabilities(driver_id: @driver) for new objects and driver_driver_availability(driver_id: @driver, id: @driver_availability) for existing driver availablities. So either you create a named route routing to the other controller (notice that these named routes are used for index, show, update and destroy as well) or you provide the url option to the form tag:

= form_for [@driver,@driver_availability], url: … # named route or routing hash

I would go with the second option.

Sign up to request clarification or add additional context in comments.

1 Comment

You should see following answer stackoverflow.com/questions/5320414/…

Your Answer

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.