【发布时间】:2013-09-09 12:52:26
【问题描述】:
我对 Ruby on Rails 很陌生,想将我的自定义 CSS 文件放入设计(注册视图)中。我将全局 CSS 放入 application.js(资产管道)中,并在我的
中放置了 2 个 Helper 函数helpers/application_helper.rb
def javascript(*files)
content_for(:head_javascript) { javascript_include_tag(*files) }
end
def stylesheet(*files)
content_for(:head_stylesheet) { stylesheet_link_tag(*files) }
end
还有我的views/layouts/application.html.erb
<!DOCTYPE html>
<%
if (controller.controller_name == "sessions") && (controller.action_name == "new")
javascript 'theme/signup'
stylesheet 'theme/signup'
end
%>
<html>
<head>
<title>Mysite</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<%= yield(:head_stylesheet) %>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= yield(:head_javascript) %>
<%= csrf_meta_tags %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<%= yield %>
</body>
</html>
然后我生成了设计视图并调整了我的 twitter 引导表单
rails generate devise:views
现在想将我的 signup.css 放在注册视图中,但是如何?
所以我创建了设计控制器,以使用我的辅助方法:
bash <(curl -s https://raw.github.com/foohey/cdc/master/cdc.sh)
现在我被困住了,因为我的助手不和我一起工作:
<%
if (controller.controller_name == "sessions") && (controller.action_name == "new")
javascript 'theme/signup'
stylesheet 'theme/signup'
end
%>
rails 中是否有一种简单的方法来处理自定义 css 文件?我是资产管道概念的新手,这有点令人困惑。
感谢您的帮助。
【问题讨论】:
标签: css ruby-on-rails ruby-on-rails-3 devise asset-pipeline