So, I have a Rails engine contained in a Rails application. I want to do something like redirect_to @record.polymorphic_relationshipin one of my kernel controllers, where @record.polymorphic_relationshipis this Picture, which is the model in the parent application. There is a path helper in the parent Rails application picture_path.
It seems to me that I should redirect the engine from the inside to the route in the parent application, using main_appsomehow. Just executing redirect_to @record.polymorphic_relationshipinside the motor controller does not work because it complains that the route picture_urldoes not exist. The same code works from the controller in the parent application.
If I do redirect_to main_app.send("#{@record.polymorphic_relationship_type.downcase}_path", @record.polymorphic_relationship), it works, but it seems hacked. Is there a better way to do this?
source
share