i am using sequel gem and postgresql database
i have a file hello.rb with code
require "rubygems"
require './post'
require "sequel"
# connect to an in-memory database
DB = Sequel.connect('postgres://ritesh:newpassword@localhost')
post = Post['ruby1', 'hello world1']
post[1]
and i created a table post and a model with code
require 'sequel'
DB = Sequel.connect('postgres://ritesh:newpassword@localhost')
class Post < Sequel::Model
set_primary_key [:category, :title]
end
when i run command ruby hello.rb .i am getting the following error hello.rb:10: undefined method `[]' for nil:NilClass (NoMethodError)
first thing i want to know for creating we should create a table with that name and then create a model?? second thing if first assumption is true then why i am getting this error??