Radu Artene Radu Artene - 2 years ago 96
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

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 Source

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

Delete it first:


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download