Okay in playing around in irb, I found that making a DB.create_table(:table_name) do block will create a table and allow for insertions and deletions using the model specified, and that opening a new irb session does not require this block to be called again. So is it then common to make a Rake task or some equivalent when starting out to create all the schemas you have planned for an app? And when a new schema is needed, use these schema modifications and migrations only once in the same fashion?
Or is there some standard place to put such configurations within the code? On Monday, April 6, 2015 at 11:01:50 PM UTC+1, Erik Griffin wrote: > > Can you give me a clear example of how to best start a new model and > database from scratch? I have been unable to find any github projects to > help guide me, and I don't understand the process. Would I have to call > create_table somewhere before I can use a Model? I'm sorry but I'm > desperately trying to wrap my head around this and the documentation seems > good for explaining individual methods but not how they all fit together in > the context of starting from scratch > > On Monday, April 6, 2015 at 4:01:36 PM UTC+1, Jeremy Evans wrote: >> >> On Monday, April 6, 2015 at 7:42:27 AM UTC-7, Erik Griffin wrote: >>> >>> Hi, I would very much like to begin using Sequel, but I am having some >>> trouble getting it to work. >>> >>> I wanted to make a basic model and run some Rspec tests. >>> >>> I have a user.rb file which looks like this: >>> >>> require 'sequel' >>> >>> class User < Sequel::Model >>> >>> primary_key :id >>> String :name >>> >> >> You appear to be trying to use Database schema modification methods >> inside a model. Don't do that. Sequel will introspect your database to >> get the information for the model. >> >> If you want to modify the database to add a table for the model, it's >> best to use migrations. See: >> >> http://sequel.jeremyevans.net/rdoc/files/doc/schema_modification_rdoc.html >> http://sequel.jeremyevans.net/rdoc/files/doc/migration_rdoc.html >> >> Thanks, >> Jeremy >> > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
