2017-07-07 31 views
0

我們正在將一些應用程序從Ruby 1.x遷移到Ruby 4.x,而不是通過選擇。從Ruby 1.x遷移Rails 4.x關係

我發現一些關係不再有效。有人可以告訴我他們是否可以在這裏看到任何對他們來說基於rails 4.2.9無效的東西?

特別,這裏是當我嘗試訪問F5Device.nodes會發生什麼:

irb(main):003:0* f = F5Device.first 
    SQL (7.8ms) USE [Networks] 
    F5Device Load (2.8ms) EXEC sp_executesql N'SELECT [dbo].[f5_devices].* FROM [dbo].[f5_devices] ORDER BY [dbo].[f5_devices].[id] ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY' 
=> #<F5Device id: 5422, name: "myDevice", environment: "UAT", feed_type_id: 1, scm_device_id: 121764, created_at: "2012-08-23 20:02:52", updated_at: "2017-01-19 10:08:08", gonefishing: 0> 
irb(main):004:0> 
irb(main):005:0* f.nodes 
/usr/local/lib/ruby/gems/2.2.0/gems/soap4r-1.5.8/lib/xsd/charset.rb:13: warning: variable $KCODE is no longer effective 
/usr/local/lib/ruby/gems/2.2.0/gems/soap4r-1.5.8/lib/soap/property.rb:68: warning: encoding option is ignored - u 
/usr/local/lib/ruby/gems/2.2.0/gems/soap4r-1.5.8/lib/soap/property.rb:69: warning: encoding option is ignored - u 
/usr/local/lib/ruby/gems/2.2.0/gems/soap4r-1.5.8/lib/soap/property.rb:70: warning: encoding option is ignored - u 
ArgumentError: wrong number of arguments (0 for 1) 
     from /usr/local/lib/ruby/gems/2.2.0/gems/soap4r-1.5.8/lib/soap/property.rb:325:in `inject' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:269:in `block in constantize' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:259:in `each' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:259:in `inject' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:259:in `constantize' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:304:in `safe_constantize' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:572:in `safe_get' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:603:in `safe_constantize' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.9/lib/active_record/inheritance.rb:154:in `block in compute_type' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.9/lib/active_record/inheritance.rb:153:in `each' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.9/lib/active_record/inheritance.rb:153:in `compute_type' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.9/lib/active_record/reflection.rb:295:in `compute_class' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.9/lib/active_record/reflection.rb:291:in `klass' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.9/lib/active_record/associations/association.rb:118:in `klass' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.9/lib/active_record/associations/collection_association.rb:41:in `reader' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.9/lib/active_record/associations/builder/association.rb:115:in `nodes' 
     from (irb):5 
     from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.9/lib/rails/commands/console.rb:110:in `start' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.9/lib/rails/commands/console.rb:9:in `start' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.9/lib/rails/commands/commands_tasks.rb:68:in `console' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.9/lib/rails/commands/commands_tasks.rb:39:in `run_command!' 
     from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.9/lib/rails/commands.rb:17:in `<top (required)>' 
     from script/rails:6:in `require' 
     from script/rails:6:in `<main>' 

應用程序/模型/ f5_device.rb

class F5Device < F5Base 
     has_many :nodes, :class_name => "F5Node", :foreign_key => "device_id" 
     has_many :members, :through => :nodes 
     has_many :group_items , :foreign_key => :device_id 
     has_many :groups, :through => :group_items 
     has_many :dependencies, :class_name => "Dependency", :foreign_key => :device_id 
     has_many :device_applications, :class_name => "F5DeviceApplication", :foreign_key => :device_id 
     has_many :applications, :through => :device_applications 
     has_many :websphere_servers, :class_name => "IisDependency", :foreign_key => :f5_device_id 

應用程序/模型/ f5_node .rb

require 'f5' 
class F5Node < F5Base 
     has_many :bigips, :class_name => "F5Bigip", :foreign_key => :group_id, :primary_key => :group_id 
     belongs_to :device, :class_name => "F5Device", :foreign_key => :device_id 
     has_many :members, :class_name => "F5Member", :foreign_key => "node_id", :dependent => :destroy 
     has_many :pools, :through => :members 
     attr_accessor :ws, :bigip, :session_status, :monitor_status, :enabled_status, :status_description, :availability_status, :state 
     after_initialize :set_ws 
+2

「我們正在遷移從紅寶石的1.x到Ruby 4.x的一些應用程序」 - 我不相信你。 ... –

+0

我認爲他的意思是從1.x到4.x,但我不確定是否有足夠的時間去編輯他們的帖子。 (他實際上說他是從ruby 1.x轉到rails 4.x) –

+1

除非他是指從ruby 1.x到rails 4.x所需的ruby,即ruby 2.x? – alexanderbird

回答

0

假設你真的是從Rails的1.x的應用程序遷移到Rails的4.2:

這可能不是你要找的答案,但official upgrade guide

如果你的應用是目前任何版本的Rails早於3.2.x的版本,在嘗試使用Rails 4.0之前,您應該升級到Rails 3.2。

同樣,

如果你的應用是目前on Rails的比3.1.X年長的任何版本,你應該嘗試更新到Rails 3.2之前升級到Rails 3.1。

等等

這似乎是官方的升級路徑是:

  1. 1〜3.0 ... ...我找不到在complete release notes blog since the very start of rails說明in the upgrade guide或任何提示。我猜測官方的路徑一次最多隻有一個主要版本,但如果你勇敢的話,你可以跳到3.0,看看會發生什麼。
  2. 3.0 to 3.1
  3. 3.1 to 3.2
  4. 3.2 to 4.0
  5. 4.0 to 4.1
  6. 4.1 to 4.2