从 Rails 2 迁移到 Rails 3 时的environment.rb 内容
我正在将应用程序从 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.rb
或 application.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
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 )不要升级。人们可能不喜欢这个答案,但从 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.
本教程帮助我完成您想做的事情: 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/
我找到答案了,所有的配置都必须到application.rb
I figure out the answer, all the configurations must go to the application.rb