对非rails应用程序使用activerecord迁移,有哪些步骤?

时间:2012-01-14 03:29:59

标签: java ruby-on-rails activerecord jruby

我有一个java应用程序,我想为此使用rails迁移。

让这项工作有哪些步骤?

到目前为止我已经这样做了:

1. installed jruby
2. installed the following gems: rspec, cucumber, rake

我是安装rails还是只安装activerecord?

有关存储Rakefile的文件夹结构的任何建议吗?我假设rake只能在rakefile所在的路径上工作吗?

如何告诉我我的数据库连接信息?

2 个答案:

答案 0 :(得分:5)

以下是一篇简洁的文章,我相信您会回答所有问题:http://community.active.com/blogs/productdev/2011/02/28/using-activerecord-3-without-rails

它讨论了如何在Sinatra中使用AR,但你会发现一切都很容易适应你的问题。

答案 1 :(得分:1)

乔丹有一个很好的答案,但它不在JRuby的背景下。

如果您正在寻找JRuby + sinatra w activerecord迁移,这是您想要的过程:

http://exposinggotchas.blogspot.com/2011/02/activerecord-migrations-without-rails.html

JRuby注意:

  1. 使用activerecord适应任何数据库的宝石
  2. config / database.yml
  3. 中修改后的“adapter:XXXX”声明

    Postgresql中的示例:

    1. 在档案中:SuperAwers0m3SinatraApp / Gemfile>> gem'activerecord -jdbcpostgresql-adapter'
    2. 在档案中:SuperAwers0m3SinatraApp / config / database.yml>> https://gist.github.com/1912785
相关问题