简体   繁体   English

样式表错误-Ruby on Rails新手

[英]Stylesheet Error - Ruby on Rails Newbie

I am currently learning ruby on rails through "Agile Web Development With Rails," and I have run into an error I cannot fix. 我目前正在通过“使用Rails进行敏捷Web开发”在Rails上学习ruby,但遇到了我无法解决的错误。 So far, I have only done some basic operations. 到目前为止,我只做了一些基本操作。 I created a scaffold with a command similar to this: 我使用以下命令创建了脚手架:

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

I then raked that: 然后我提出:

rake db:migrate

Once that was run, I went into the db/seeds.db file and filled this newly created table with this data: 一旦运行,我进入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)

Once again, I raked this data: 再次,我倾斜了这些数据:

rake db:seed

After this was all complete, I loaded up localhost:3000/products and everything was working fine. 完成所有操作后,我加载了localhost:3000 / products,一切正常。 However, the book wanted to add some css code to make things look a bit better. 但是,这本书想要添加一些CSS代码以使外观看起来更好一些。 Once I added the CSS (exactly as the book had it), I got an error when I loaded localhost:3000/products (error: http://postimage.org/image/3qfpta4w7/ ). 一旦添加了CSS(完全如本书所述),加载localhost:3000 / products时出现错误(错误: http : //postimage.org/image/3qfpta4w7/ )。 I assume my error has something to do with my css, but I do not know what to do. 我认为我的错误与CSS有关,但我不知道该怎么办。 Here is my 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;
}
}

I have tried changing several things, but now success has followed. 我试图改变几件事,但是现在成功了。 Any and all input on this would be appreciated. 任何和所有对此的投入将不胜感激。 (PS bonus points for naming your favorite rails book to learn from). (PS奖励积分用于命名您最喜欢的Rails书籍以供学习)。

Check following 检查以下

  .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;
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM