Whenever i tried to use
Table.create :a=>"a", :b=>"b"
or
tab=Table.new
tab.a="a"
tab.b="b"
tab.save!
produces
NoMethodError: undefined method `name’ for nil:NilClass
my table model is
class Table < ActiveRecord::Base
set_table_name "table"
set_primary_key "id"
end
As everyone has stated,
TABLEis a reserved word. For future reference, if you really wanted to use these reserved words, in your sql queries(I know you are using the AR abstraction), you would have to use backticks like so:However I would highly suggest changing your table name. One other thing to note is that you do not have to set your primary key to
idbecause rails by default usesidfor the PK.