[英]Rails asset pipeline how to link to a specific .js file on production
So I have a view which basicaly loads in a given .js file and it works fine on local host but when i push it to heroku it dies. 因此,我有一个视图,该视图基本上会加载到给定的.js文件中,并且在本地主机上运行良好,但是当我将其推送到heroku时,它就会死掉。
basically in the controller i define 基本上在我定义的控制器中
@script = '/assests/script_name.js?body=1' @script ='/assests/script_name.js?body=1'
and in the view i call 我认为
%script{:src => @script, :type => "text/javascript"} %script {:src => @script,:type =>“ text / javascript”}
and this loads the correct scripts in development but in production it can't find them 这会在开发中加载正确的脚本,但在生产中找不到它们
what am i missing? 我想念什么?
In your controller... 在您的控制器中...
@script = view_context.asset_path('script_name.js')
If it was me, I'd do this instead though: 如果是我,我会这样做:
controller: @script = 'script_name'
控制器: @script = 'script_name'
view: = javascript_include_tag @script
查看: = javascript_include_tag @script
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.