Specify precision and scale attributes for decimal number with scaffold/model/migration generators in Rails 3.2.0

By using the short hand  :decimal{precision, scale}, rails generator lets you generate number migration with decimal and scale. You could use {precision, scale} or {precison-scale} or {precision.scale} shorhand:

rails g scaffold Product title:string price:decimal{8,2}

the above would generate a migration of:

t.decimal :price, :precision => 8, :scale => 2

NOTE: sadly, this feature is so broken as of the release of 3.2.0 and is addressed in the bug #4602.

Howto make Paperclip to re-process images w/o deleting images

If you add new styles into your Image model and want Paperclip to process those styles w/o deleting existing images, you simply goes into your RoR console and type:

Image.all.each &:reprocess!
Follow

Get every new post delivered to your Inbox.

Join 57 other followers