我对为什么没有指定控制器的js文件感到有些困惑,比如说post.js不会在任何帖子视图中渲染任何Java脚本,例如document.write(“ hello”),而是在application.js之后做到每个视图
Its because in your application.html.erb
you are including application.js
with <%= javascript_include_tag "application" %>
but your controller specified javascripts will render only after the specific action is executed. For example if you are creating a new post and your form has remote: true
, After the form is submitted it will trigger the create action which will render create.js.erb
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.