从 Rails 2 迁移到 Rails 3 时的environment.rb 内容

发布于 2024-12-06 08:57:29 字数 575 浏览 1 评论 0原文

我正在将应用程序从 Rails 2.3 更新到 Rails 3.1,而且我是 Rails 新手。我关注了 RailsCast 并得到了一些想法。有人请帮助我找到旧环境变量的放置位置。这些是我的旧 environment.rb 中的四段代码

1:

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

2:

if RUBY_PLATFORM =~ /java/
  require 'rubygems'
  RAILS_CONNECTION_ADAPTERS = %w(jdbc)
end

3:

CalendarDateSelect.format = :hyphen_ampm

4:

Mime::Type.register "text/csv", :csv

我该把它放在哪里,新的 environment.rbapplication.rb?

I'm updating an application from rails 2.3 to rails 3.1, and I'm new to rails. I followed the RailsCast and got some idea. Somebody please help me for where to place my old environment variables. These are the four pieces of code in my old environment.rb

1:

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

2:

if RUBY_PLATFORM =~ /java/
  require 'rubygems'
  RAILS_CONNECTION_ADAPTERS = %w(jdbc)
end

3:

CalendarDateSelect.format = :hyphen_ampm

4:

Mime::Type.register "text/csv", :csv

Where do I place this, the new environment.rb or application.rb?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

千年*琉璃梦 2024-12-13 08:57:29

3 和 4 在初始化程序(配置/初始化程序)中,我认为您不需要 1,并且我不确定 2,但我认为您只需要添加 gem 'activerecord-jdbc-adapter' 到您的 Gemfile。 (我还没有在rails中使用过jruby,所以老实说我不知道​​,这只是一个猜测,因为我在某个地方看到过它)

3 and 4 in an initializer (config/initializers), i don't think you need 1, and i am not sure about 2, but i think you just need to add gem 'activerecord-jdbc-adapter' to your Gemfile. ( i haven't used jruby with rails yet, so i honestly don't know, it's just a guess, because i saw it somewhere )

同尘 2024-12-13 08:57:29

不要升级。人们可能不喜欢这个答案,但从 2.3 到 3 不值得付出努力。从头开始?也许使用 3,由你决定。

Don't upgrade. People may not like that answer, but it's not worth the effort to go from 2.3 to 3. Starting from scratch? Maybe use 3, up to you.

久随 2024-12-13 08:57:29

本教程帮助我完成您想做的事情: http: //gregmoreno.ca/rails-3-upgrade-part-1-booting-the-application/

This tutorial helped me do what you are trying to do: http://gregmoreno.ca/rails-3-upgrade-part-1-booting-the-application/

沫尐诺 2024-12-13 08:57:29

我找到答案了,所有的配置都必须到application.rb

I figure out the answer, all the configurations must go to the application.rb

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文