Search code examples
ruby-on-railshyperlinklink-to

using link_to for an external link calling from form fields


I've previously been able to use the following code to link to an external site listed in a form. However, I can't get it work here. My controller defines the parameter and it's in the view and in my db/schema (t.string "website").

Is there something I'm missing?

/show

 <p>
   <strong>Website:</strong>
   <%= link_to @woman.website %>
 </p>

The website shows up in active admin in my db, but not as a link. This is what the form partial asks the user to input:
/_form

 <div class="form-group">
    <%= f.label :website %><br>
    <%= f.text_field :website,  class: "form-control" %>
 </div>

Every time I click the link, it just reloads the same page I'm on. Would appreciate any insight.


Solution

  • You missed the href part, try this

    <%= link_to @woman.website, @woman.website %>