Rails 4:使用js.erb文件作为部分文件

时间:2015-08-11 17:52:26

标签: ruby-on-rails ruby-on-rails-4

是否可以将.js.erb文件定义为部分文件?我有几个.js.erb的代码可以像部分一样移动到公共文件中,然后我就可以在其上调用render。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

与普通部分相同的规则:将文件命名为以<tomcat-users> <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. --> <!-- NOTE: The sample user and role entries below are wrapped in a comment and thus are ignored when reading this file. Do not forget to remove <!.. ..> that surrounds them. --> <role rolename="tomcat"/> <role rolename="role1"/> <role rolename="admin" /> <user username="admin" password="V3g$lb7p9pp" roles="standard,manager,admin,manager-gui"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/> </tomcat-users> 开头,并在主文件中将其命名为_yourfile.js.erb

虽然javascript是一种编程语言,但您可能想要重构代码而不是诉诸于此