Html 如何允许用户将网站链接放入文本区域并显示Rails 4中可单击的链接?
并且用户可以把一个党的描述。 用户还可以键入任何链接作为说明 但是,用户保存后,他键入的链接不可单击。 我必须复制链接地址并粘贴到浏览器中才能访问该网站 以下是Html 如何允许用户将网站链接放入文本区域并显示Rails 4中可单击的链接?,html,ruby-on-rails,Html,Ruby On Rails,并且用户可以把一个党的描述。 用户还可以键入任何链接作为说明 但是,用户保存后,他键入的链接不可单击。 我必须复制链接地址并粘贴到浏览器中才能访问该网站 以下是视图/parties/_form.html.erb: <%= form_for(@party, multipart: true) do |f| %> <div id="error_explanation"> <ul><%= @party.errors.full_messages.f
视图/parties/_form.html.erb
:
<%= form_for(@party, multipart: true) do |f| %>
<div id="error_explanation">
<ul><%= @party.errors.full_messages.first if @party.errors.any? %></ul>
</div>
<div class="field">
<%= f.label :title %><br>
<%= f.text_field :title, :class => "form-control", placeholder: 'Type title' %>
</div>
<div class="field">
<%= f.label :location %><br>
<%= f.text_field :location, :class => "form-control", placeholder: 'Type location' %>
</div>
<div class="field">
<div class="form-group">
<label>time</label>
<%= f.datetime_select :time %>
</div>
</div>
<div class="field">
<%= f.label :description %><br>
<a style="text-decoration:none;" title="Suggest!" data-toggle="popover" data-trigger="hover" data-placement="top" data-content="Ticket? Any Link? Tell me more!"><%= f.text_area :description, :class => "form-control", :rows => "3" %></a>
</div>
<div class="field">
<%= f.label :image %><br>
<%= f.file_field :image %>
</div>
<p>
</p>
<div class="actions">
<%= f.submit "Let's post it", :class => "btn btn-primary", :id => "load", 'data-loading-text' => "Uploading...".html_safe %>
</div>
<p>
</p>
<% end %>
您可以使用
variable\u name.html\u safe
来允许将variable\u name
中的文本解释为html并呈现为html。如果variable\u name
是从用户生成的内容派生出来的,请务必小心操作。您可以使用variable\u name.html\u safe
将variable\u name
中的文本解释为html并呈现为html。如果variable\u name
是从用户生成的内容派生出来的,请务必小心操作。Tl;dr使用来自的自动链接
查看帮助程序
长答案你基本上有两个选择:
Tl;dr使用来自的
自动链接
查看帮助程序
长答案你基本上有两个选择:
在视图/parties/show.html.erb中@party.description.html\u safe
不工作。。仍然不可单击。在视图/parties/show.html.erb@party.description.html\u safe
中,未工作。。仍然不能点击。
For example, if a user typed,
"Hi we have party tomorrow at 12:00 pm.
Also more information is at www.facebook.com/samplepartybrabrabra
ticket is $5 per person."