0

In .html.erb <%= link_to 'the listing', "years/1846", class: "btn btn-primary" %> works. How can I put this in an Action Text field and have it be a link?

It will be hard coded to a specific record as shown. years is a table, model, etc in my app. Doesn't have to be a Bootstrap button, but does need to look like a link, so will need to be styled.

Greg
  • 2,359
  • 5
  • 22
  • 35

1 Answers1

0

You can add the raw html output of your link_to code directly to the ActionText field and it should work. Something like roster.description += ‘the listing’ etc (obviously roster and description are placeholder names for the ActiveRecord object and the ActionText field name)

obiruby
  • 379
  • 1
  • 6
  • Thank you, but I'm not understanding your suggestion. The ActionText is the docs/_form.html.erb and the field name is content. So `doc.content += the listing' which is still rendered literally. It can't be entered into the link helper that Rails Action Text provides because that has to start with `http`. – Greg Mar 08 '21 at 16:10
  • hmm, I'm sorry but I guess I'm not clear on what the desired output is, then. why not just manually enter the html link like this, then: ` – obiruby Mar 09 '21 at 04:12
  • That would probably work except during development, I am adding data during development on `localhost:3000`. – Greg Mar 09 '21 at 15:53
  • 1
    True.... One workaround would be to create a helper method that uses gsub and Rails.env to dynamically decide which server to display in the view. – obiruby Mar 09 '21 at 21:06
  • Thank you. Even if I knew how to do it might be more complication. But maybe I'll look into it. Or maybe create another field with the info needed. Or maybe some other way – Greg Mar 10 '21 at 02:09