我已经设置了application.html.erb以使用以下代码链接到样式表
<%= stylesheet_link_tag 'stylesheets/style', :media => 'screen' %>
但是,当我在浏览器窗口中加载localhost时,它会打印此代码
<link href="/assets/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />
当我直接查看文件时,我显示此错误
路由错误
没有路线匹配[GET]"/assets/stylesheets/style.css"
我已经阅读了一些其他问题,默认情况下rails在公共/样式表中查找,所以我不确定它为什么要查看资产?
我还尝试将css文件移动到assets目录,只是为了查看它是否可行,但它仍然不起作用并给出相同的路由错误.
被困在这几天,这真的是我的头脑,所以感谢你能给我的任何帮助.
提前致谢
我一直在成功地遵循Rails教程3,直到我进入第7章并实现了用户模型,现在我的rspec一直在失败.
这是我的user.rb文件输出
class User < ActiveRecord::Base
attr_accessible :name, :email
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :name, :presence => true,
:length => { :maximum => 50 }
validates :email, :presence => true,
:format => { :with => email_regex },
:uniqueness => { :case_sensitive => false }
validates :password, :presence => true,
:confirmation => true,
:length => { :within => 6..40 }
before_save :encrypt_password
# Return tue if the user's password matches the submitted password.
def has_password?(submitted_password)
encrypted_password == encrypt(submitted_password)
end
def self.authenticate(email, submitted_password) …Run Code Online (Sandbox Code Playgroud)