Radu Artene Radu Artene - 7 months ago 25
Ruby Question

Ruby on Rails scaffolding error

I'm trying to scaffold a model with the following command:

rails generate scaffold Ofertruck title:string country:string city:string lwh:string comment:text postalcode:integer weigth:decimal


the result I get in the migration file is the following:

class CreateOfertrucks < ActiveRecord::Migration
def change
create_table :ofertrucks do |t|
t.string :title
t.string city :country
t.decimal :weigth

t.timestamps null: false
end
end
end


What it generates is wrong, and it will give an error by
bundle exec rake db:migrate

it is possible to see at line

t.string city :country


why it generates like this, since I made sure to put a space between every data base column?

Answer

It didnt give me an error, probably you are mistyped somewhere.

Delete it first:

#destroy

rails d scaffold Ofertruck title:string country:string city:string lwh:string comment:text postalcode:integer weigth:decimal

Try this one:

# Generate again

rails g scaffold ofertruck title country city lwh comment:text postalcode:integer weigth:decimal

#