zoukankan      html  css  js  c++  java
  • 关于rails2.0.2中使用scaffold报错的问题

    最近在学习ROR,买了一本叫《Web开发敏捷之道--应用Rails进行敏捷Web开发,第2版》的书照着做。
          当做到第六章《任务A:货品维护》时候,却进行不下去了,照着书敲上了下面的代码
    class AdminController < ApplicationController
      scaffold :products
      def admin
        render :text => "Hello"
      end
    end
     
          当运行的时候却报如下错误:
    undefined method `scaffold' for AdminController:Class
     
          没办法,女朋友只能向我求救了。我记得rails以前的时候可以运行的,怎么现在不行了?是不是版本升级了与之前的老版本不兼容?类、方法起来变化?(我女朋友学习是使用ruby是1.8.6,rails是2.0.2)于是我赶忙去查了一下资料,结果发现是因为Rails2.0.2把scaffold 剥离为插件,也就是说Rails2.0.2里面不能直接使用scaffold了。于是我就先安装了它。
          
    NetBeans-右键点击工程depot-选择Rails Plugins-选择New Plugins-选择scaffolding进行安装。
    或者Depot>ruby script/plugin install http://dev.rubyonrails.com/svn/rails/plugins/scaffolding/
     
           然后重新运行项目,访问,这回报了另一个错误:
    undefined method `paginate' for #<AdminController:0x3b62210>
     
           晕死,不用说,这个方法什么的也应该是在Rails2.0.2的时候剥离了,再查一下资料。
    原来这是一个分页的功能,那么让我们来重新安装一下。 不知道为什么,我在NetBeans里加入了
    svn://errtheblog.com/svn/plugins
    的URL,可是NetBeans提示搜索加入成功,却搜索不出来插件。先不管什么原因了,解决问题最重要。接下来我使用TortoiseSVN通过
    Depot>ruby script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination
    的URL把插件
    classic_pagination下载回来,然后把文件夹复制到项目的vendor\plugins的文件夹内,如:depot\vendor\plugins。
            然后重新启动项目,接下来访问http://127.0.0.1:3000/admin,看看,是不是一切正常了?呵呵,那么就让我们继续进行书本上的学习吧!
  • 相关阅读:
    jquery实现选项卡(两句即可实现)
    常用特效积累
    jquery学习笔记
    idong常用js总结
    织梦添加幻灯片的方法
    LeetCode "Copy List with Random Pointer"
    LeetCode "Remove Nth Node From End of List"
    LeetCode "Sqrt(x)"
    LeetCode "Construct Binary Tree from Inorder and Postorder Traversal"
    LeetCode "Construct Binary Tree from Preorder and Inorder Traversal"
  • 原文地址:https://www.cnblogs.com/hannover/p/1381171.html
Copyright © 2011-2022 走看看