On my 사이트 링크를 통해 그의 개인 사용자가 개인 프로필 개외부 웹 사이트. 내가 이름 아래 사이트 url 을 postgresql 데이터베이스를 웹사이트 보관합니다. When I get a 테스트 결과, 난 항상 uirl 다음과 같습니다.
http://localhost:3000/www.example.com
내가 보기에 인드렉스트 라자레프 다음과 같습니다.
<% provide(:title, 'All projects') %>
<h1>All projects</h1>
<%= will_paginate %>
<ul class="microposts">
<%= render @microposts %>
</ul>
<%= will_paginate %>
그리고 내 _micropost.html.erb 다음과 같습니다.
<li>
<span class="title"><%= micropost.title %></span>
<span class="website"><%= link_to micropost.website, micropost.website %></span>
<span class="content"><%= micropost.content %></span>
<span class="timestamp">
Posted <%= time_ago_in_words(micropost.created_at) %> ago.
</span>
</li>
누구나 할 수 있는 높여줍니까 돕는다구요 (I& # 39, m a beginner 로)?
KR, 파비안
이 말은 틀렸다니까 저장하는 url 을 해석할 수 있기 때문에 '없이' http://로 기술입니까 상대치 url 입니다. 방금 해야 할 일은 이 같은 일이.
link_to micropost.website, "http://#{micropost.website}"
아님 추가하기에서는 full_url it& # 39 의 경우 모델 '' 방식을 추가한 없습니다.
그나저나 너 '의 일부를 사용하여 @micropost can& # 39, t, t # 39 타임코드가 doesn& 때문에' (rec.601 '또는' 불과 '@microposts 마이크로포스트').
아래 코드를 대체하십시오 시도해 볼 수 있습니다.
'<, %) = link_to " 그러하매 너희의 label";, :target = > http" 그러하매 너희의 " 연동. " _blank"; %>. '
이 새 탭에서 열리는 링크를 만들게 됩니다.
뭐 그런 작업을 수행할 수 있습니다.
link_to micropost.website, url_for(micropost.website)
참조 [레일 Api: url_for] [1]
사용할 수 있는 레일 콘솔이군요. 그냥 유형: 콘솔:
micropost = Micropost.first
helper.link_to micropost.website, url_for(micropost.website)
그 결과 진실이며당신이 지켜보리니 구체화하십시오.
또한 익힐 수 있는 경로 및 uirl 차이를 알고 있어야 합니다. 참조 [루비 온 레일즈 안내선.] [2]
[1]: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html # method-i-url_for [2]: http://guides.rubyonrails.org/routing.html # 경로 및 url
고로 권리. &Quot, http://" 추가해야 합니다. 웹 사이트에 대한 속성. 데이터베이스 모델 인스턴스 및 저장 후 검증중 전에 이 접두어입니다 추가해야 합니다.
[URI 클래스] [1] 루비 사용할 수 있습니다.
= link_to micropost.website, URI::HTTP.build({:host => micropost.website}).to_s, target: "_blank"
# <a target="_blank" href="http://www.example.com">www.example.com</a>
[1]: # 메서드입니다 캜 구축하십시오 .0/libdoc/uri/rdoc/uri/http.html http://ruby-doc.org/stdlib-2.0
내가 list. [열린우리당 포스트랭크] (https://github.com/postrank-labs/postrank-uri) '를 전달하기 전에 컴팩트형 정상화에 uirl link_to'.
class User < ActiveRecord::Base
def normalized_webpage
webpage && PostRank::URI.normalize(webpage).to_s
end
end
그런 다음,, website" " 사용할 수 있는 'link_to user.normalized_webpage 대상: 'in your 경치말이야 _blank" "; 예를 들어 '을' 이렇게 하면 # 39 의 경우 추가 http://로 uirl it& 없습니다.
그래서 결국 그냥 이렇게 뭔가를해야합니다 in my view:
<%= link_to (content_tag(:i, "help", class: 'material-icons tiny')), " http://www.google.com.mx", target: "_blank", rel: "alternate" %>
이는 동일합니까:
<%= link_to "help", "http://www.google.com.mx", target: "_blank", rel: "alternate" %>
이를 통해 다른 사람에게 됐으면 좋겠다 "고 말했다.
그리고 그분은 우리가 let& # 39 의 말하도다 @person 링크 (@person.link) # = >. www.google.com
누구도 만들 수 있는 이 같은 일이
def extlink(link)
if link.include?("http://")
puts link
else
link.insert(0, "http://")
link
end
end
또한 해당 파일이 resistor1.prt 할 수 있는
<% @person.each do |p| %>
<%= link_to 'External', extlink(p.link) %>
<% end %>
작동됨 가져다줄래요