2017-11-01 1 views
0

가입 테이블, 작업 사람들레일은 지역 변수 또는 메소드를 정의되지 않은 : 나는 회사와 작업, 위치와 같은 다른 모델의 공동 테이블이

_companies.html.erb

<% if company.companylogo %> 
    <%= link_to (image_tag(company.companylogo.url(:medium), :class => "fw img-responsive", :alt =>"company logo")), company_path(company) %> 
    <% else %> 
    <%= link_to (image_tag("http://via.placeholder.com/405x285", :class => "fw img-responsive", :alt =>"company logo")), company_path(company) %> 
    <% end %> 



    <p <%= link_to truncate(company.name, :length => 20), company_path(company), :class => "" %> </p> 

와 함께 부분 렌더링 /index.html.erb 나는 부모의 회사 로고와 회사 이름을 보여줍니다

<%= render job.companies if job.companies.present? %> 

에 의해 부분적으로 위 회사의 모든 콘텐츠를 렌더링 할 수 있어요.

지금 내가 다른 부분을 만들어 로고에서 회사 이름을 구분합니다 : _seperatename.html.erb

**<p <%= link_to truncate(company.name, :length => 20), company_path(company), :class => "" %> </p>** 

내 질문은, 작업/index.html.erb에서 어떻게 할 수 _seperatename.html.erb를 렌더링합니까?

내가 시도 <% = 렌더링 '회사/seperatename'%>

는 # < #에 대한 오류를 ActionView ::에서 템플릿 : 오류/작업 정의되지 않은 지역 변수 또는 메서드 '회사'가 발생합니다 : 나는 일반 텍스트로 _seperatename.html.erb에서 루비의 컨텐츠를 교체하는 경우 0x007f99b6b239f8는>

그러나 그것은 당신이 부분에 변수를 전달해야

+0

그것은 당신이 무엇을 요구 비트 불분명하다. 하지만,'render partial : ...'이 필요하다고 생각합니다. [DOCS] (http://api.rubyonrails.org/classes/ActionView/PartialRenderer.html) – Abhi

답변

관련 문제