मैं "एडवांटेज डेटाबेस सर्वर" एडॉप्टर एक्सटेंशन पर काम कर रहा हूं, एक विरासत डेटाबेस से बात करने की कोशिश करने के लिए, जिस तक मेरी पहुंच है (जो अभी भी सक्रिय उपयोग में है)।
मैंने "एडवांटेज" जेम को अपडेट किया है ताकि यह रूबी के नए/सक्रिय संस्करणों पर काम करे https://github.com /t12nslookup/advantage और देखा है कि मेरी activerecord-advantage-adapter की कॉपी https://github .com/t12nslookup/activerecord_advantage_adapter रूबी 1.9.3 और रेल 3.2.22 पर काम करता है
मैं इसे रेल 6 के साथ काम करने के लिए मजबूर करने की कोशिश करने के लिए काम कर रहा हूं, और एक साधारण "रूबी" स्क्रिप्ट के साथ उचित सफलता मिली है जिसमें रत्नों की "आवश्यकता" होती है और डेटा तक पहुंच होती है, लेकिन मुझे काम करने के लिए एक ही सरल डेटाबेस क्वेरी नहीं मिल सकती है रेल कंसोल पर।
मैं डब्लूएसएल 2 में चल रहा हूं, अगर इससे कोई फर्क पड़ता है (लेकिन मुझे विश्वास नहीं है।
रूबी 2.7.0p0 (2019-12-25 संशोधन 647ee6f091) [x86_64-linux], रेल 6.0.3.3
मैंने एक्टिवरेकॉर्ड-एडवांटेज-एडाप्टर जीथब प्रोजेक्ट में एक रेल 6 शाखा जोड़ी है।
रूबी लिपि:
jadams@Temp046317:~/code/ais-lims$ more ../testme.rb
require 'rubygems'
gem 'advantage'
gem "activerecord-advantage-adapter"
require "active_record"
ActiveRecord::Base.establish_connection(
adapter: 'advantage',
options: 'ServerType=Local|Remote; ReadOnly=True; CommType=TCP_IP; Compression=INTERNET',
database: '//172.27.176.1:6262/c$/ads/db/'
)
class Discount < ActiveRecord::Base
self.table_name = 'DISCOUNT'
self.sequence_name = :autogenerated
end
puts Discount.all.inspect
puts Discount.count
jadams@Temp046317:~/code/ais-lims$ ruby ../testme.rb
#<ActiveRecord::Relation [#<Discount >, #<Discount >, #<Discount >, #<Discount >]>
4
रेल कंसोल:
jadams@Temp046317:~/code/ais-lims$ more config/database.yml
development:
adapter: 'advantage'
options: 'ServerType=Local|Remote; ReadOnly=True; CommType=TCP_IP; Compression=INTERNET'
database: '//172.27.176.1:6262/c$/ads/db/'
jadams@Temp046317:~/code/ais-lims$ more app/models/discount.rb
class Discount < ApplicationRecord
self.table_name = 'DISCOUNT'
self.sequence_name = :autogenerated
end
jadams@Temp046317:~/code/ais-lims$ rails c
Running via Spring preloader in process 728
Loading development environment (Rails 6.0.3.3)
2.7.0 :001 > puts Discount.all.inspect
Traceback (most recent call last):
1: from (irb):1
NoMethodError (undefined method `to_sym' for nil:NilClass)
2.7.0 :002 > puts Discount.count
Traceback (most recent call last):
2: from (irb):1
1: from (irb):2:in `rescue in irb_binding'
NoMethodError (undefined method `to_sym' for nil:NilClass)
डिबग कैसे करें, या इस मुद्दे को कहां खोजें, इस पर कोई संकेत, मैं आभारी रहूंगा।
जॉन
1 उत्तर
@rmlockerd और @ruby_object दोनों डीबग करने में मदद करने में सही थे, लेकिन दिन के अंत में मैंने कोड के अनुभाग को इस तरह से लिखा था जो काम नहीं करता था।
डिबगिंग कुंजी थी
संबंधित सवाल
नए सवाल
ruby-on-rails
रूबी ऑन रेल्स रूबी में लिखा गया एक ओपन सोर्स फुल-स्टैक वेब एप्लिकेशन फ्रेमवर्क है। यह लोकप्रिय एमवीसी फ्रेमवर्क मॉडल का अनुसरण करता है और इसे "कॉन्फिगरेशन ओवर कॉन्फिगरेशन" अप्रोच डेवलपमेंट के दृष्टिकोण के लिए जाना जाता है।