Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created June 15, 2015 09:43
Show Gist options
  • Save anonymous/398814f1b3053578d8a8 to your computer and use it in GitHub Desktop.
Save anonymous/398814f1b3053578d8a8 to your computer and use it in GitHub Desktop.
So I'm trying to set the value of a primary key in my model...I'm thinking rails should be doing this on it's own but I'm not sure. My question is what should I be putting in place of "DEFAULT"?
tabel schema
create_table "Model_Labels", primary_key: "labelid", force: :cascade do |t|
t.string "name", limit: 255
end
Portion of code where I want to set the value of "labelid"
model_labels = Model_Labels.new
model_labels.labelid = DEFAULT
model_labels.name = item['name']
model_labels.save
label_id = model_labels.labelid
NOTE label_id get's called latter in the code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment