added decoration support

This commit is contained in:
Senad Uka
2015-11-24 10:29:46 +01:00
parent 31876c0c1a
commit b93660b264
4 changed files with 12 additions and 3 deletions

View File

@@ -3,7 +3,8 @@ class Item < ActiveRecord::Base
CSV_COL = {
:code => 0,
:input_price => 1,
:list_price => 2
:list_price => 2,
:decoration => 3
}
belongs_to :unit
@@ -117,6 +118,7 @@ class Item < ActiveRecord::Base
else
item.current_input_price = row[CSV_COL[:input_price]]
item.list_price = row[CSV_COL[:list_price]]
item.decoration = row[CSV_COL[:decoration]]
item.save!
end
end

View File

@@ -0,0 +1,5 @@
class AddDecorationToItem < ActiveRecord::Migration
def change
add_column :items, :decoration, :string
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150726161256) do
ActiveRecord::Schema.define(version: 20151124061357) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -135,6 +135,7 @@ ActiveRecord::Schema.define(version: 20150726161256) do
t.decimal "weight", precision: 5, scale: 3
t.integer "delivery_time_estimation_id"
t.integer "brand_id"
t.string "decoration"
end
create_table "link_banners", force: :cascade do |t|

View File

@@ -8,7 +8,8 @@ class MultiMediaDescription < ActiveRecord::Base
end
def resized_url
url.gsub('/upload/v','/upload/c_lpad,h_281,w_375/v')
decoration_slug = item.decoration.present? ? "/#{item.decoration}" : ""
url.gsub('/upload/v',"/upload/c_lpad,h_281,w_375#{decoration_slug}/v")
end
end