如何通过rails上的特定控制器为本地开发和生产(使用Heroku)加载css和js
这将加载所有样式表和javascipt:
管理控制器:
用户控制器:
但是我希望它能从特定的控制器加载
例如:
管理控制器:
用户控制器:
发布于 2016-08-08 10:16:17
您可以为不同的视图创建不同的布局,并为此使用特定的文件。
admin folder->
file1.css
file.2.css
application.css => there your files
user folder->
the same as admin而不是在layout folder admin.slim和user.slim中创建两个文件。
在application_controller.rb中,为您的需要设置布局,布局文档
layout :set_layout
private
def set_layout
case controller
when 'user'
"user_layout"
when "admin"
"admin_layout"
else
"application"
end
end
endhttps://stackoverflow.com/questions/38825165
复制相似问题