Roy - 2 years ago 131

Ruby Question

I am trying to generate the following a model named

`PriceUsdOneMinIntervals`

`rails generate model PriceUsdOneMinInterval unix_timestamp:integer usd_high:decimal :precision[20] :scale[8] usd_low:decimal :precision[20] :scale[8] usd_open:decimal :precision[20] :scale[8] usd_close:decimal :precision[20] scale[8]`

I have referred to this api while making the above statement.

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

TRy this

```
rails generate model PriceUsdOneMinInterval :unix_timestamp, :integer,
:usd_high, :decimal, precision: 20, scale: 8, :usd_low, :decimal, precision: 20,
scale: 8, :usd_open, :decimal, precision: 20, scale: 8,
:usd_close, :decimal, precision: 20, scale: 8
```

OR

generate migration with just field names and data_types and then change you can change the values in migration

```
def change
add_column :price_usd_one_min_intervals, :unix_timestamp, :integer
add_column :price_usd_one_min_intervals, :usd_high, :decimal, precision: 20, :scale: 8
add_column :price_usd_one_min_intervals, :usd_low, :decimal, precision: 20, scale: 8
add_column :price_usd_one_min_intervals, :usd_open, :decimal, precision: 20, scale: 8
add_column :price_usd_one_min_intervals, :usd_close, :decimal, precision: 20, scale: 8
end
```

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