1
난 레일 프로젝트가있다. application.html.slim
에서레일스보기에서 content_for 메소드가 정의되지 않은 이유는 무엇입니까?
I가 가지고 또한 상기 제어부는 컨텐츠가 대응하는 뷰와 방법 new
을 갖는다
def javascript(*files)
content_for(:html_head) do
javascript_include_tag(*files)
end
end
helper_method :javascript
: 메서드가 제어기 SearchController
에서는
doctype html
html
head
title RailsMongoidPj
= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true
= javascript_include_tag "application", "data-turbolinks-track" => true
= csrf_meta_tags
meta content="width=device-width, initial-scale=1.0" name="viewport"
= yield(:html_head)
body
= yield
:
= javascript('/vendor/assets/javascript/handelbars.runtime.js')
- content_for :html_head do
script#entry-template type="text/x-handlebars-template"
| template content
n 오류 :
undefined method `content_for' for #<SearchFlickrController:0x007f8e4f2bae78>
Extracted source (around line #3):
1/search flickr api page
2
3 = javascript('/vendor/assets/javascript/handelbars.runtime.js')
4
5 - content_for :html_head do
6 script#entry-template type="text/x-handlebars-template"
이유가 content_for
인 이유는 무엇입니까? 표준 rails
방법이 아닌가요?
당신이 일을 여전히 볼 외부 방법을 가지고 만들기 위해 무엇을 알 수 있습니까? 나는이 해결책을 여기에서 찾았다 : http://stackoverflow.com/questions/6571753/rails-3-1-asset-pipeline-how-to-load-controller-specific-scripts. – static
SearchHelper에 메서드를 추가했는데 이제 작동합니다. – static