【发布时间】:2014-01-30 19:38:15
【问题描述】:
我正在使用 ruby 2/rails 4 并尝试将我的 javascript 放入 <head> 但所有 javascripts 都将结束页面,
我正在尝试使用此代码但不起作用:
在 app/views/layouts/index.html.haml:
!!!
%html
%head
%meta{ content: 'text/html; charset=utf-8', 'http-equiv' => 'Content-Type' }
%meta{ content: 'text', name: 'description'}
:javascript
//code...
或将此代码放在 app/views/index.html.haml 的末尾:
- content_for :head do
:javascript
//code...
这两个选项对我不起作用,有人可以给我点灯吗?
【问题讨论】:
-
为什么要在布局文件中添加代码而不是使用
javascript_include_tag和/或 application.js?
标签: javascript ruby-on-rails ruby-on-rails-4 haml