Ruby SequelGem Can't figure out to set fields for DB that already exists

604 Views Asked by At

I have a DB table called Agents how do I get Sequel to let me talk to it?

The table already exists but nothing I've done seems to work.

Heres the Model:

class Agents < Sequel::Model(:agents)
  set_primary_key :id
  one_to_many :branches
end

I thought I had to run the create table method so here's that to:

DB.create_table? :agents do
    primary_key :id
    integer :office_count, null: false, default: 0
    text :name
    text :website
    text :main_office_city
    text :main_office_post_code
    boolean :sales
    boolean :lettings
    boolean :lettings_and_sales
end

but when I try to do this:

a = Agents.create(name: "test")
a.save

I just get:

`block in set_restricted': method name= doesn't exist (Sequel::MassAssignmentRestriction)

The error happens regardless if the create_table? block is executed or not.

So what am I doing wrong?

0

There are 0 best solutions below