样式表错误 - Ruby on Rails新手

时间:2012-06-11 20:30:01

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1

我目前正在学习ruby on rails" Agile Web Development With Rails,"我遇到了一个我无法解决的错误。到目前为止,我只做了一些基本的操作。我创建了一个脚手架,其命令类似于:

rails generate scaffold Product title:string description:text image_url:string price:decimal

然后我倾斜了:

rake db:migrate

运行后,我进入了db / seeds.db文件并用这些数据填充了这个新创建的表:

Product.delete_all
Product.create(:title => 'Web Design for Developers',
               :description => 
               %{<p>
               <em>Web Design for Developers</em> will show you how to make your
               web-based application look professionally designed. We'll help you
               learn how to pick the right colors and fonts, avoid costly interface
               and accessibility mistakes -- your application will really come alive.
               We'll also walk you through some common Photoshop and CSS techniques
               and work through a web site redesign, taking a new design from concept
               all the way to implementation.
               </p>},
               :image_url =>   '/images/rails.png',    
               :price => 42.95)
# . . .
Product.create(:title => 'Programming Ruby 1.9',
               :description =>
               %{<p>
               Ruby is the fastest growing and most exciting dynamic language
               out there. If you need to get working programs delivered fast,
               you should add Ruby to your toolbox.
               </p>},
               :image_url => '/images/rails.png',
               :price => 49.50)
# . . .

Product.create(:title => 'Rails Test Prescriptions',
               :description => 
               %{<p>
               <em>Rails Test Prescriptions</em> is a comprehensive guide to testing
               Rails applications, covering Test-Driven Development from both a
               theoretical perspective (why to test) and from a practical perspective
               (how to test effectively). It covers the core Rails testing tools and
               procedures for Rails 2 and Rails 3, and introduces popular add-ons,
               including Cucumber, Shoulda, Machinist, Mocha, and Rcov.
               </p>},
               :image_url => '/images/rails.png',
               :price => 43.75)

再次,我收集了这些数据:

rake db:seed

在这一切完成后,我加载了localhost:3000 /产品,一切正常。但是,这本书想要添加一些css代码,以使事情看起来更好一些。一旦我添加了CSS(就像书中的那样),当我加载localhost:3000 / products(错误:http://postimage.org/image/3qfpta4w7/)时出现错误。我认为我的错误与我的css有关,但我不知道该怎么办。这是我的css:

.products {
table {
border-collapse: collapse;
}
table tr td {
    padding: 5px;
    vertical-align: top;
}
.list_image {
    width: 60px;
    height: 70px;
 
}
.list_description {
    width: 60%;
dl {
margin: 0;
}
dt {
    color: #244;
    font-weight: bold;
    font-size: larger;
}
dd {
    margin: 0;
}
}
.list_actions {
    font-size: x-small;
    text-align: right;
    padding-left: 1em;
}
.list_line_even {
    background: #e0f8f8;
}
.list_line_odd {
    background: #f8b0f8;
}
}

我尝试过改变一些事情,但现在已经成功了。对此的任何和所有输入将不胜感激。 (P.S.奖励积分,用于命名您喜爱的导轨书籍以供学习)。

1 个答案:

答案 0 :(得分:0)

检查以下

  .products {
        table {
            border-collapse: collapse;
        }
        table tr td {
            padding: 5px;
            vertical-align: top;
        }
        .list_image {
            width: 60px;
            height: 70px;
        }
        .list_description {
            width: 60%;
            dl {
                margin: 0;
            }
            dt {
                color: #244;
                font-weight: bold;
                font-size: larger;
            }
            dd {
                margin: 0;
            }
        }
        .list_actions {
            font-size: x-small;
            text-align: right;
            padding-left: 1em;
        }
        .list_line_even {
            background: #e0f8f8;
        }
        .list_line_odd {
            background: #f8b0f8;
        }
    }