小编Jam*_*mie的帖子

CSS未在应用中加载

CSS不会加载到我的rails应用程序中.这是位于view/products中的index.html.erb文件:

 <h1>Listing products</h1>

<table>
<% @products.each do |product| %>
  <tr class="<%= cycle('list_line_odd', 'list_line_even') %>">

  <td>
    <%= image_tag(product.image_url, :class=> 'list_image') %>
  </td>

  <td class="list_description"> 
    <dl>
      <dt><%= product.title %></dt>
      <dd><%= truncate(strip_tags(product.description), :length=> 80) %></dd>
    </dl>
  </td>

  <td class="list_actions">
    <%= link_to 'Show', product %><br/>
    <%= link_to 'Edit', edit_product_path(product) %><br/>
    <%= link_to 'Destroy', product, 
              :confirm=> 'Are you sure?',
              :method=> :delete %>
  </td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New product', new_product_path %>
Run Code Online (Sandbox Code Playgroud)

然后我将application.html.erb文件放在view/layouts中.此文件应将css链接到html.

<!DOCTYPE html> 
<html>
<head>
  <title>Depot</title>
  <%= stylesheet_link_tag  "application" …
Run Code Online (Sandbox Code Playgroud)

css assets ruby-on-rails ruby-on-rails-3 asset-pipeline

32
推荐指数
4
解决办法
5万
查看次数

初学者:rails语法

我刚开始在铁轨上学习红宝石.我正在使用'敏捷Web开发与Rails,第4版,Rails 3.1'一书.我安装了rails 3.1.3.

在本书的例子中显示如下代码:

<%= f.text_area :description, rows: 6 %>
Run Code Online (Sandbox Code Playgroud)

但是这段代码不起作用.我必须更改为代码:

<%= f.text_area :description, :rows=> 6 %> 
Run Code Online (Sandbox Code Playgroud)

这有效,但我不明白为什么.有人可以解释为什么这样在书中?

谢谢

ruby ruby-on-rails

3
推荐指数
1
解决办法
126
查看次数