Skip to content

Instantly share code, notes, and snippets.

@kamui
Created August 14, 2012 22:13
Show Gist options
  • Save kamui/3353489 to your computer and use it in GitHub Desktop.
Save kamui/3353489 to your computer and use it in GitHub Desktop.
/gems/sequel-3.38.0/lib/sequel/model/base.rb:1756:in `block in set_restricted': shopper is a restricted column (Sequel::Error)
# You just need sequel, fabrication, ffaker, and sqlite3 gems
require 'sequel'
require 'sqlite3'
require 'logger'
require 'fabrication'
require 'ffaker'
DB = Sequel.sqlite
# DB.loggers << Logger.new($stdout)
Sequel::Model.raise_on_save_failure = false
DB.instance_eval do
create_table :orders do
primary_key :id
Integer :quantity
Integer :price_in_cents
foreign_key :shopper_id, :shoppers
end
create_table :shoppers do
primary_key :id
String :email
end
end
class Order < Sequel::Model
many_to_one :shopper
set_allowed_columns :quantity, :price_in_cents
end
class Shopper < Sequel::Model
one_to_many :orders
end
Fabricator :order do
quantity { rand 1..10 }
price_in_cents { rand 100..999_99 }
shopper
end
Fabricator :shopper do
email { Faker::Internet.email }
end
shopper = Fabricate(:shopper)
order = Fabricate(:order)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment