zoukankan      html  css  js  c++  java
  • Rails+Mongodb之non browser app之敏捷开发

    第一个问题:Rails程序是否需要nonbrowser app?

    这个答案是肯定的,当你的Rails程序上线之后,象备份你的数据库这样后台操纵表格等需求一定会提上日程,这也是为什么Rails的经典指南<Agile Web Development With Rails>其最新第四版加了一章介绍如何开发non browser app,可惜的是,它介绍的内容是基于active record,不适用于mongodb,另外还有一个问题,这本书介绍的方法明显比较落伍,并不是 Agile Way!

    第二个问题:怎么Agile开发nonbrowser app?

    本文介绍的就是如何敏捷开发Rails+Mongodb的nonbrowser app

    1、创建一个目录utils

    mkdir utils

    2、创建一个文件util_helper.rb,内容如下:

    ENV["RAILS_ENV"] ||= 'development'

    require File.expand_path("../../config/environment", __FILE__)

     

    # Requires supporting ruby files with custom matchers and macros, etc,

    # in spec/support/ and its subdirectories.

    Dir[Rails.root.join("utils/support/**/*.rb")].each {|f| require f}

     

    MyApp::Application.configure do |config|

    end

    其中ENV["RAILS_ENV"] ||= 'development'表示我们对development数据库操作

    require File.expand_path("http://www.cnblogs.com/config/environment", __FILE__)这一行特别重要,就是它来让我们的APP具有和Rails Server一样的环境,包括数据库参数

    Dir[Rails.root.join("utils/support/**/*.rb")].each {|f| require f}这一行是为将来作准备,如果有自定义的参数设置,可以放在support目录下

    3、然后创建一个文件countposts.rb,其中Post是一个model,可以直接引用。

    require File.expand_path("../util_helper", __FILE__)

    puts Post.find(:all).size

    4、OK,运行ruby countposts.rb,得到结果如:10

    总结:实现敏捷nonbrowser app的要点:与APP共同环境变量、参数;可直接引用MVC的Class

  • 相关阅读:
    C/S 架构和B/S架构的区别
    LoadRunner工作原理
    修改密码测试用例
    登录测试用例
    上传测试点
    avd 配置信息详解
    创建模拟器
    命令模式下启动模拟器,加载软件
    启动模拟器时出现Failed to create Context 0x3005
    SDK Manager更新时出现Failed to fectch URl https://dl-ssl.google.com/android/repository/addons_list.xml, reason: Connection to https://dl-ssl.google.com ref
  • 原文地址:https://www.cnblogs.com/mobileinternet/p/2542948.html
Copyright © 2011-2022 走看看