Forum: Ruby Create with console

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
027f88d17068dde230d0261d70bea262?d=identicon&s=25 Simon Eric (noumedem)
on 2014-06-11 18:12
Hello everybody

i want to create a data with the console on an model in db.

This is the model:

class CreateBancas < ActiveRecord::Migration
  def change
    create_table :bancas do |t|
      t.string :nome
      t.string :cognome
      t.integer :numero
      t.integer :scadenza
      t.integer :type

      t.timestamps
    end
  end
end

When i do an query like this:

Banca.create!(:nome => "eric", :cognome => "noumedem", :scadenza =>
"2016", :numero => "123", :type => "1")
 I have an error like so:


ActiveRecord::SubclassNotFound: Invalid single-table inheritance type: 1
is not a subclass of Banca
  from
/home/eric/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/inheritance.rb:178:in
`subclass_from_attrs'
  from
/home/eric/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/inheritance.rb:22:in
`new'
  from
/home/eric/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/validations.rb:39:in
`create!'
  from (irb):307
  from
/home/eric/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands/console.rb:90:in
`start'
  from
/home/eric/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands/console.rb:9:in
`start'
  from
/home/eric/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands.rb:62:in
`<top (required)>'
  from bin/rails:4:in `require'
  from bin/rails:4:in `<main>'


What is wrong here?

Thank you
027f88d17068dde230d0261d70bea262?d=identicon&s=25 Simon Eric (noumedem)
on 2014-06-11 18:33
I resolved a problem. Rails don't like calling an colunm "type"
This topic is locked and can not be replied to.