开发者

Rails 3.1 simple question

I would like to use the nested_form gem for my application that uses Rails 3.1 rc5. When I install the gem there is a js file placed in public/javascripts. i am supposed to place this line in my app: <%= javascript_include_tag :开发者_如何学Pythondefaults, "nested_form" %> would this line let my app access the js file or should i do <%= javascript_include_tag :defaults, "/javascripts/nested_form" %>


try this

In config/application.rb

uncomment this line

config.action_view.javascript_expansions[:defaults] = %w(nested_form.js)

All that this line is doing is loading your nested_form.js as a default, you can add many files like %w(nested_form.js javascript1.js javascript2.js)

Then in views/layouts add this line

<%= javascript_include_tag :defaults %>

Now the nested_form.js will get loaded with all the defaults .js files


If the asset pipeline is turned on in your application.rb:

config.assets.enabled = true

Try putting the nested_form.js file in /app/assets/javascripts.

Then it will get included with your other javascripts if you use the line:

<%= javascript_include_tag "application" %> in your views.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜