Commit 51453c895a68e7990cad6fdd6ab63698bec4c79f

Authored by Braulio Bhavamitra
1 parent 0475e746

metadata: Don't crash on product creation (Closes #81)

Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
plugins/metadata/lib/ext/product.rb
@@ -7,7 +7,7 @@ class Product @@ -7,7 +7,7 @@ class Product
7 url: proc{ |p, plugin| plugin.og_url_for p.url }, 7 url: proc{ |p, plugin| plugin.og_url_for p.url },
8 gr_hascurrencyvalue: proc{ |p, plugin| p.price.to_f }, 8 gr_hascurrencyvalue: proc{ |p, plugin| p.price.to_f },
9 gr_hascurrency: proc{ |p, plugin| p.environment.currency_unit }, 9 gr_hascurrency: proc{ |p, plugin| p.environment.currency_unit },
10 - title: proc{ |a, plugin| "#{p.name} - #{p.profile.name}" }, 10 + title: proc{ |p, plugin| "#{p.name} - #{p.profile.name}" if p },
11 description: proc{ |p, plugin| ActionView::Base.full_sanitizer.sanitize p.description }, 11 description: proc{ |p, plugin| ActionView::Base.full_sanitizer.sanitize p.description },
12 12
13 image: proc{ |p, plugin| "#{p.environment.top_url}#{p.image.public_filename}" if p.image }, 13 image: proc{ |p, plugin| "#{p.environment.top_url}#{p.image.public_filename}" if p.image },
@@ -17,7 +17,7 @@ class Product @@ -17,7 +17,7 @@ class Product
17 17
18 see_also: [], 18 see_also: [],
19 site_name: proc{ |p, plugin| plugin.og_url_for p.profile.url }, 19 site_name: proc{ |p, plugin| plugin.og_url_for p.profile.url },
20 - updated_time: proc{ |p, plugin| p.updated_at.iso8601 }, 20 + updated_time: proc{ |p, plugin| p.updated_at.iso8601 if p.updated_at },
21 21
22 'locale:locale' => proc{ |p, plugin| p.environment.default_language }, 22 'locale:locale' => proc{ |p, plugin| p.environment.default_language },
23 'locale:alternate' => proc{ |p, plugin| p.environment.languages - [p.environment.default_language] if p.environment.languages }, 23 'locale:alternate' => proc{ |p, plugin| p.environment.languages - [p.environment.default_language] if p.environment.languages },