Search code examples
ruby-on-railsbackbone.jsmarionetteeco

Rails link_to in eco template


I'm trying to create a link in an eco template using Backbone Marionette with a rails backend. I'm trying to let the user download the data in CSV/XLS. If I was in a regular rails view I could do <%= link_to "CSV", surveys_path(format: "csv") %>.

Does anyone know how I could generate a link_to piece like above within an eco template?


Solution

  • I actually opted to use the js-routes gem to set the route in my view and then just access it in the template via <%= @csv_route %>.

    @model.set(csv_route: Routes.survey_path(@model.get('id'), {format: 'csv'}), xls_route: Routes.survey_path(@model.get('id'), {format: 'xls'}))