简体   繁体   English

Hartl rails教程第5章错误

[英]Hartl rails tutorial chapter 5 error

I have been trying to work out the basic layout of the site but the following error shows up every time i run the application on local server.我一直在尝试制定站点的基本布局,但是每次我在本地服务器上运行应用程序时都会出现以下错误。

    ExecJS::ProgramError in StaticPages#home
    Showing E:/workspace/sample_app/app/views/static_pages/home.html.erb         where line #13 raised:

    TypeError: Object doesn't support this property or method            
    </div>

    <%= link_to image_tag("rails.png", alt: "Rails logo"),
                'http://rubyonrails.org/' %>

Here is the code for the file home.html.erb这是文件 home.html.erb 的代码

    <div class="center jumbotron">
    <h1>Welcome to the Sample App</h1>

    <h2>
    This is the home page for the
    <a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
     sample application.
    </h2>

    <%= link_to "Sign up now!", '#', class: "btn btn-lg btn-primary" %>
    </div>

    <%= link_to image_tag("rails.png", alt: "Rails logo"),
              'http://rubyonrails.org/' %>

Based on our comments, your issue is with windows running rails.根据我们的评论,您的问题是 windows 运行 rails。 There are a number of issues, particularly with the way javascript/coffeescript work in rails that causes this error to pop up in windows.有很多问题,尤其是 javascript/coffeescript 在 rails 中的工作方式会导致此错误在 windows 中弹出。 It's very difficult to troubleshoot all these issues, and I have not found a good resource that walks you through it.对所有这些问题进行故障排除非常困难,而且我还没有找到一个很好的资源来引导您完成它。 I have found online and met real life programmers who attempted to run rails on windows for 4 hours or a day before understanding the hurdles and switching operating systems.我在网上找到并遇到了现实生活中的程序员,他们试图在 Windows 上运行 Rails 4 小时或一天,然后才了解障碍和切换操作系统。 You can attempt to figure out how to get windows to work, but you'll spend a bit of time (maybe 40 solid hours, but I have no idea how deep the issues go) fighting against the OS, when you should be coding.您可以尝试弄清楚如何让 Windows 工作,但是当您应该编码时,您将花费一些时间(可能是 40 个固定小时,但我不知道问题有多深)与操作系统作斗争。

You should switch to a linux or mac operating system.您应该切换到 linux 或 mac 操作系统。 I use linux ubuntu.我使用linux ubuntu。 You can still use the same computer and run a virtual machine - that's running windows, and running linux or mac on top of it - if you have a pretty good computer.您仍然可以使用同一台计算机并运行虚拟机 - 运行 Windows,并在其上运行 linux 或 mac - 如果您有一台非常好的计算机。 There are plenty of resources and tutorials on virtual machines available through google searches.通过谷歌搜索可以获得大量关于虚拟机的资源和教程。

Alternatively, you can run dual operating systems and get both linux and windows working on the same pc.或者,您可以运行双操作系统并让 linux 和 windows 在同一台电脑上运行。 When you start your computer up, it gives you an option to load one or the other.当您启动计算机时,它会为您提供加载一个或另一个的选项。 Or just drop your operating system and run linux.或者干脆放弃你的操作系统并运行 linux。 That's the easiest option.这是最简单的选择。 Very little troubleshooting and you get right into it.很少有故障排除,您就可以直接进入。

I found/guessed your error by looking at this information.我通过查看此信息发现/猜测了您的错误。

where line #13 raised:

TypeError: Object doesn't support this property or method         

At first I thought you had a typo, which is why I asked you to post your code, but there didn't one there.一开始我以为你有错别字,这就是为什么我让你发布你的代码,但那里没有。 After googling 'TypeError: Object doesn't support this property or method' I was seeing a lot of hits citing windows errors.在谷歌搜索“类型错误:对象不支持此属性或方法”后,我看到了很多引用 Windows 错误的点击。 In the future try googling your error first to save yourself some time and get a better understanding of coding.将来尝试先用谷歌搜索你的错误,以节省一些时间并更好地理解编码。

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

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