本文介绍了样式表错误 - Ruby on Rails 新手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在通过使用 Rails 进行敏捷 Web 开发"学习 ruby​​ on rails,但遇到了无法修复的错误.到目前为止,我只做了一些基本的操作.我用类似这样的命令创建了一个脚手架:

I am currently learning ruby on rails through "Agile Web Development With Rails," and I have run into an error I cannot fix. 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

然后我说:

rake db:migrate

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

Once that was run, I went into the db/seeds.db file and filled this newly created table with this data:

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

这一切都完成后,我加载了 localhost:3000/products 并且一切正常.然而,这本书想要添加一些 css 代码来让事情看起来更好一些.一旦我添加了 CSS(正如书中所说的那样),当我加载 localhost:3000/products 时出现错误(错误:http://postimage.org/image/3qfpta4w7/).我认为我的错误与我的 css 有关,但我不知道该怎么做.这是我的 css:

After this was all complete, I loaded up localhost:3000/products and everything was working fine. However, the book wanted to add some css code to make things look a bit better. 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/). I assume my error has something to do with my css, but I do not know what to do. Here is my 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. 为您最喜欢的 Rails 书籍命名以供学习的奖励积分).

I have tried changing several things, but now success has followed. Any and all input on this would be appreciated. (P.S. bonus points for naming your favorite rails book to learn from).

推荐答案

检查以下内容

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

这篇关于样式表错误 - Ruby on Rails 新手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 22:53