我有3个JS函数,我在每个函数中使用Rails render
来根据JS函数内部的条件加载我的Rails部分。
我知道我无法将这些功能放在资产JS中,因为render
不会在资产中使用。
我有很多静态页面,我现在想要的是,让我的所有静态页面都可以使用3个JS函数。
我的StaticPagesController如下:
class StaticPagesController < ApplicationController
def home
end
def about
end
def faq
end
def contact
end
end
我尝试但没有效果
views/static_pages/static_pages.js.erb
views/layouts/application.js.erb
views/shared/static_pages.js.erb
views/application/application.js.erb
public/application.js.erb
我该怎么办?我错过了什么吗?
注意: 我正在使用资产管道。