I have the following situation:
2 Tables (actualle there are more, but these two are relevant here):
sqlite> .schema vlans
CREATE TABLE "vlans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"name" varchar(255), "description" text, "vlanname" varchar(255),
"vlan" integer, "vlantype" varchar(255) DEFAULT 'normal',
"primaryvlan" integer DEFAULT 0, "created_at" datetime, "updated_at"
datetime, "switchingdomain_id" integer, "ipv4network_id" integer);
CREATE INDEX "index_vlans_on_ipv4network_id" ON
"vlans" ("ipv4network_id");
CREATE INDEX "index_vlans_on_switchingdomain_id" ON
"vlans" ("switchingdomain_id");
sqlite> .schema ipv4networks
CREATE TABLE "ipv4networks" ("id" INTEGER PRIMARY KEY AUTOINCREMENT
NOT NULL, "name" varchar(255), "intaddress" integer, "intnetmask"
integer, "description" text, "created_at" datetime, "updated_at"
datetime, "environment_id" integer);
CREATE INDEX "index_ipv4networks_on_environment_id" ON
"ipv4networks" ("environment_id");
sqlite> select count(*) from vlans where ipv4network_id is null;
351
#########################
vlans model:
belongs_to :ipv4network
ipv4networks model:
has_many :vlans
#########################
I want to have a view with all vlans which have not been assigned to a
ipv4network.
Right now i'm testing in the console and this gets me confused:
(591 vlans alltogether, 240 are assigned, 351 with "ipv4network_id is
NULL")
>> Vlan.apply_scopes(:order_by => :vlan, :ipv4network_is_not => true).count
=> 240
>> Vlan.apply_scopes(:order_by => :vlan, :ipv4network_is_not => false).count
=> 591
>> Vlan.apply_scopes(:order_by => :vlan, :ipv4network_is => false).count
=> 591
>> Vlan.apply_scopes(:order_by => :vlan, :ipv4network_is => true).count
=> 0
>> Vlan.apply_scopes(:order_by => :vlan, :ipv4network_id_is_not => nil).count
=> 591
Is this a bug in hobo or am i missing something?
Thanks for all help in advance!
Stefan
##########################
my environment:
Mac OSX 10.6.6
$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10]
$ rails -v
Rails 2.3.11
$ gem list
*** LOCAL GEMS ***
actionmailer (2.3.11, 2.3.5)
actionpack (2.3.11, 2.3.5)
activerecord (2.3.11, 2.3.5)
activeresource (2.3.11, 2.3.5)
activesupport (2.3.11, 2.3.5)
hobo (1.0.3)
hobofields (1.0.3)
hobosupport (1.0.3)
hoe (2.9.1)
ipaddress (0.7.0)
magic_encoding (0.0.2)
minitest (1.6.0)
mysql (2.8.1)
rack (1.1.1, 1.0.1)
rails (2.3.11, 2.3.5)
rake (0.8.7)
rake-compiler (0.7.6)
rdoc (2.5.8)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
will_paginate (2.3.15)
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
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/hobousers?hl=en.