2

I have an image entity exposes a url to a rails controller.

The controller shows the image conforming to some business logic. (ex it deletes the image if everybody in the group viewed it,...)

  expose :media_url do |message, options|
    #TODO inject the rails route helper
  end

How could I inject the rails named route helper into the code above?

Any other hint is also welcome :)

Boti
  • 3,275
  • 1
  • 29
  • 54

2 Answers2

3

This helped

Rails.application.routes.url_helpers.message_image_url message.id
Boti
  • 3,275
  • 1
  • 29
  • 54
0

This may help:

https://github.com/intridea/grape/wiki/Grape-and-Rails-Path-Helpers

# Include rails helpers include Rails.application.routes.url_helpers expose :media_url do |message, options| # Something like asset_url(message.media_url) end
Stan Bondi
  • 4,118
  • 3
  • 24
  • 35