Wednesday, 15 April 2015

ruby - redirect to parent Rails app's route from within engine -



ruby - redirect to parent Rails app's route from within engine -

so have rails engine contained within rails app. want redirect_to @record.polymorphic_relationship in 1 of engine's controllers, @record.polymorphic_relationship picture, model in parent app. there's picture_path path helper in parent rails app.

i sense ought able redirect within engine route in parent app using main_app somehow. doing redirect_to @record.polymorphic_relationship within engine controller doesn't work, because complains no picture_url route exists. same code works within controller in parent app.

if redirect_to main_app.send("#{@record.polymorphic_relationship_type.downcase}_path", @record.polymorphic_relationship), works, seems hacky. there improve way of doing this?

redirect_to main_app.url_for(@record.polymorphic_relationship)

ruby-on-rails ruby routing

No comments:

Post a Comment