ruby-on-railsurllink-topins

Customized links in rails


I would like to create custom links into rails - for example I have my users filling out this form when they create a new pin:

<%= form_for @pin, html: { multipart: true } do |f| %>
  <% if @pin.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@pin.errors.count, "error") %> prohibited this pin from being saved:</h2>

      <ul>
      <% @pin.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="form-group">
    <%= f.label :image %>
    <%= f.file_field :image, class: "form-control" %>
  </div>


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

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

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

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

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

  <div class="form-group">
    <%= f.submit class: "btn btn-primary" %>
  </div>
<% end %>

In my the pins views I want to create custom url to tweet: So I have this url: http://twitter.com/intent/tweet?text="HERE GOES THE CUSTOM PART"

How could I integrate at the end of this url, for example: <%= f.label :description %>

Any ideas on how I could do such a thing ?


Solution

  • The correct syntax should be

    <%= link_to "Link text here", "https://twitter.com/intent/tweet?text=#{@pin.description}" %>