ruby-on-railsruby-on-rails-4grape-entity

How to use rails routes in grape entities?


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 :)


Solution

  • This helped

    Rails.application.routes.url_helpers.message_image_url message.id