My bad. What I'm working on is a Sequel Model for network interfaces originating from some SNMP poller data that I have. My problem stems from the fact that singular form of the word 'address' is somehow 'addres' on the associations in my objects.
*require 'sequel'* * * *class Device < Sequel::Model * * one_to_many :interfaces* *end* *class Interface < Sequel::Model* * many_to_one :device* * many_to_many :ipaddress, :null => true* *end* *class Ipaddress < Sequel::Model* * many_to_one :device* * many_to_many :interfaces,* * :left_key => :ipaddress_id,* * :right_key => :interface_id,* * :join_table => :interfaces_ipaddresses,* * :null => false* *end* The IRB output below shows those method names. *irb(main):025:0> Interface.first.methods.grep(/addre/i)* *=> [:ipaddress_id, :ipaddress_id=, :ipaddress_dataset, :ipaddress, :add_ipaddres, :remove_ipaddres, :remove_all_ipaddress]* And when I try the following I get what I think is the problem I described above. *irb(main):038:0* Interface.first.ipaddress_dataset* *NameError: uninitialized constant Ipaddres* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/inflections.rb:125:in `constantize'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/inflections.rb:125:in `module_eval'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/inflections.rb:125:in `constantize'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:57:in `block in associated_class'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:265:in `block (2 levels) in cached_fetch'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:265:in `fetch'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:265:in `block in cached_fetch'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:263:in `fetch'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:263:in `cached_fetch'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:57:in `associated_class'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:1138:in `block in def_many_to_many'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:1471:in `_dataset'* * from /usr/local/lib/ruby/gems/1.9.1/gems/sequel-3.40.0/lib/sequel/model/associations.rb:1103:in `block in def_association_dataset_methods'* * from (irb):38* * from /usr/local/bin/irb:12:in `<main>'* I was thinking reflections would have something to do with my problem. And thanks to all who reply to my problem. :-) On Wednesday, November 28, 2012 4:06:39 PM UTC-7, Jeremy Evans wrote: > > On Wednesday, November 28, 2012 2:52:26 PM UTC-8, Jarrod Manzer wrote: >> >> Hello, >> I've been having some problems with the word "address" in terms of >> pluralization and singularization of a field name. >> When I try to name my model 'Ipaddress' it produces new methods like the >> following... >> >> :ipaddress_id >> :ipaddress_id= >> :ipaddress_dataset >> :ipaddress >> :add_ipaddres <----- missing an 's' >> :remove_ipaddres <-also missing an 's' >> :remove_all_ipaddress >> >> For the two incorrectly named methods I cannot seem to find the cause of >> to fix it. I was hoping someone here might have an answer. >> I'm using Ruby 1.9.3p194 and sequel (3.40.0). >> >> >> > First, I can only assume you are talking about naming associations, not > models, based on the methods you list. It appears as though are you > creating a *_to_many association using :ip_address as the name as the name > instead of :ip_addresses. *_to_many association names must be plural, this > is explicitly mentioned in the documentation. > > If that doesn't solve your issue, you probably should post the code you > are using. While I appreciate a good guessing game as much as the next > person, it's not a very efficient approach to debugging. > > Jeremy > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/_u3PaDHRJqUJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
