Can I Do STI And Still Use Polymorphic Path Helpers?
I am using Single Table Inheritance and have comments on all the subclasses. I am only using 1 controller for all the different STI types. When the form_for helper generates a URL for a subtype it tries to use a helper for the subtype, but I want it to use the helper for the parent.
This is the error I get:
undefined method `subclasstypename_comments_path' for #<ActionView::Base:0x41ef27c>
The path helper it 'should' use is
Yep, just use
Say your base class is
Account, which is subclassed to
@account.is_a? LoginAccount? #=> true
Then you can just do a
form_for [@account.becomes(Account), @comment] do |f| ...
- → Trigger a click with jQuery using link_to of rails 4
- → Adding html data attribute to simple_forms input
- → How to remove parameters from the root URL if it does I18n
- → passing parameters to rails back end from an ajax call
- → Blocking ?page= in robots.txt
- → react js and rails Updating state on a component with active record relationship
- → State not passed into prop
- → Cannot read property 'modalIsOpen' of undefined
- → Objects not valid issue
- → How to map API params to model
- → Consuming webhooks shopify-api
- → How to add ScriptTag on shopify_api gem?