I made an error and generated my Item model with string field instead of integer. Here is my migration
class CreateItems < ActiveRecord::Migration
def change
create_table :items do |t|
t.string :name
t.string :url
t.text :photo
t.string :price
t.timestamps null: false
end
end
end
But right now I want to sort my items by price field and rails sorts it bad way because it is stored as string. For example it thinks that price 9 is bigger than 1111111111. Right now I order them like this:
@items=Item.where(:category_id => @active_category_id).order(:price)
What do I do?
