1
레일즈 3.0을 사용하고 있습니다. 보기 show.html.erb
에 인 /public/javascripts/
에있는 Javascript 파일을 추가하고 싶습니다.레일에 자바 스크립트 추가하기
show.html.erb
파일은 내가 추가하는 방법 궁금하네요 템플릿 application.html.erb
에서 <head>...</head>
참여한다.
레일즈 3.0을 사용하고 있습니다. 보기 show.html.erb
에 인 /public/javascripts/
에있는 Javascript 파일을 추가하고 싶습니다.레일에 자바 스크립트 추가하기
show.html.erb
파일은 내가 추가하는 방법 궁금하네요 템플릿 application.html.erb
에서 <head>...</head>
참여한다.
추가 할 수는 일반적인 스타일 시트 레이아웃을 가정하면 다음 application.html.erb
에 :
<%= javascript_link_tag 'show' if params[:action] == 'show' %>
당신은 지금처럼 <head>
섹션에 content_for
PARAMS 플러스 yield
을 사용할 수 있습니다 : 내가 생각
layout.html.erb
<head>
<%= yield(:header) if @content_for_header %>
</head>
product/show.html.erb
<% content_for :header do -%>
<%= javascript_link_tag 'show_product' %>
<% end -%>
@ Nathan은 show.html.erb에만 사용되는 경우 가장 완벽한 답변을 제공하고, content_for 매개 변수를 사용하면 yield가 더할 나위없이 좋습니다. (그냥 Nathan이 js tag : D로 자신의 CSS 태그를 변경해야만한다) – sameera207
@ sameera207 * fixed * 고마워, 롤, 내가 뭘 생각하는지 모르겠다 : P –
'''javascript_include_tag'''가 아닌가요? http://apidock.com/rails/v4.1.8/ActionView/Helpers/AssetTagHelper/javascript_include_tag –