我是Sinatra的新手,我试图从ERB文件中引用样式表。我已经尝试了“Loading Stylesheets in Sinatra”中使用的方法,但样式表仍未加载。引用样式表
我的HTML在views/index.rb中,样式表是views/styles/main.css。控制器逻辑位于app.rb.
当我将它加载到本地服务器上时,HTML本身显示。
的文件夹结构是:
|-- app.rb
|-- config.ru
|-- Gemfile
|-- Gemfile.lock
|-- lib
|-- spec
| |-- spec_helper.rb
|-- views
| |-- index.erb
| |-- styles
| | |-- main.css
app.rb是:
get '/' do
erb :index
end
index.erb没有工作:
<link href="<%= url('views/styles/main.css') %>" rel="stylesheet" type="text/css" />
<link href="<%= url('/main.css') %>" rel="stylesheet" type="text/css" />
我的回购是:https://github.com/natstar93/Thermostat-day3
可以有人帮我弄清楚如何引用样式表?
你的意思是https://github.com/natstar93/Thermostat-Api? – matt
是的,对不起,我会在帖子中更新 – Natstar