현재 올바르게 div에 텍스트 링크가 있습니다. <%= link_to 'Show', profile %>
. 나는 아래는 내 블록에 그것을 시도하지 않고 나에게 undefined local variable or method 'profile'
div에서 링크 만들기 - Ruby on Rails
<%= link_to profile do %>
<div id="profiles" class="transitions-enabled">
<% @profiles.each do |profile| %>
<div class="box panel panel-default">
<div class="panel-body">
<%= image_tag profile.image.url(:medium) %>
<%= profile.artist %><br/>
<%= link_to 'Show', profile %>
</div>
</div>
<% end %>
</div>
<% end %>
내 원래 블록을 준다 적용 할 때 링크
<%= link_to root_path do %>
<div>Hey!</div>
<% end %>
비록로 사업부를 설정하는 적절한 방법이라고 읽고 연결시 :
<div id="profiles" class="transitions-enabled">
<% @profiles.each do |profile| %>
<div class="box panel panel-default">
<div class="panel-body">
<%= image_tag profile.image.url(:medium) %>
<%= profile.artist %><br/>
<%= link_to 'Show', profile %>
</div>
</div>
<% end %>
</div>
내 컨트롤러 :
class ProfilesController < ApplicationController
before_action :set_profile, only: [:show, :edit, :update, :destroy, :id]
# GET /profiles
# GET /profiles.json
def index
@profiles = Profile.all
end
# GET /profiles/1
# GET /profiles/1.json
def show
end
# GET /profiles/new
def new
@profile = Profile.new
end
#...
- 당신이 질문에가있을거야 넣어 경우 당신이 원하는 것을하기위한 레일 코드를 제공하기는 쉽지만 ... 출력 HTML을 어떻게 보이길 원하나요? 그냥 예를 들어 ... –
@RichardJordan은 그리드가있어서 각 "프로파일"을 클릭 할 수있게하고 싶습니다 - > http://cl.ly/image/3I1F2e3r0f08 – Jadam
당신의 위의 예는 링크 안에 링크가 있습니다 - 그래서 나는 당신이 그것을 나오기를 바라고있는 것에 대해 다소 혼란스러워합니다. 출력 할 기본 html 구조를 보여줄 수 있습니다. 효율적으로 레일스 코드를 사용하면 –