On Jan 24, 1:43 pm, Jeremy Evans <[email protected]> wrote: > On Jan 24, 9:54 am, Glen <[email protected]> wrote: > > > > > > > > > > > I have the following Model: > > > module DB > > LOCAL = Sequel.sqlite("#{File.expand_path("../../../../db/ > > janitor.db", __FILE__)}") > > > class User < Sequel::Model > > > class << self > > def create_table > > LOCAL.create_table? :users do > > String :login > > String :id > > String :first_name > > String :last_name > > primary_key :login > > end > > end > > > def delete_table > > LOCAL.drop_table(self.table_name) > > end > > > def no_role > > Net::LDAP::Filter.present("uid") & > > Net::LDAP::Filter.negate(Net::LDAP::Filter.present("pdsrole")) > > end > > end > > end > > end > > I don't see where you are actually creating/dropping the table. You > have methods that do so, but those methods don't appear to be called > anywhere. Even if they are called (as you say later), you need to > make sure the model picks up the changes, which you can do by > User.dataset = User.dataset. > > You could use the schema plugin to do something similar to what you > are doing. However, my usual recommendation is just to do any schema > modification stuff before creating the model class (i.e. above the > User < Sequel::Model line), so you don't need to worry about it. > > Jeremy
Some other issues with the code: :login is specified as the PK so you have to 'unrestrict_primary_key' in the model if you want to explicitly set it. You should be using the primary_key option on the column rather than the primary_key method. String :login, :primary_key => true For troubleshooting you could specify a logger to see the SQL that Sequel is executing require 'logger' LOCAL.loggers << Logger.new($stdout) Rohit -- You received this message because you are subscribed to the Google Groups "sequel-talk" 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/sequel-talk?hl=en.
