2

Rails へのカスタム リンクを作成したいと考えています。たとえば、ユーザーが新しいピンを作成するときに、このフォームに記入してもらいます。

<%= 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 %>

私のピンビューで、ツイートするカスタム URL を作成したい: だから私はこの URL を持っている: http://twitter.com/intent/tweet?text= "HERE GOES THE CUSTOM PART"

この URL の最後にどのように統合できますか。たとえば: <%= f.label :description %>

どうすればそのようなことができるかについてのアイデアはありますか?

4

1 に答える 1

3

正しい構文は次のとおりです。

<%= link_to "Link text here", "https://twitter.com/intent/tweet?text=#{@pin.description}" %>
于 2014-07-02T16:59:59.293 に答える