automatically identify ad type

This commit is contained in:
albert
2011-12-21 18:41:17 -05:00
parent 5e3b243b67
commit 67448d4636
4 changed files with 10 additions and 5 deletions

View File

@@ -55,7 +55,7 @@ private
tag_implication = TagImplication.where("antecedent_name = ? and consequent_name = ?", token[1], token[2]).first
raise "Implication for #{token[1]} not found" if tag_implication.nil?
tag_implication.destroy
else
raise "Unknown token: #{token[0]}"
end

View File

@@ -50,6 +50,12 @@ class Advertisement < ActiveRecord::Base
image_size = ImageSize.new(File.open(image_path, "rb"))
self.width = image_size.get_width
self.height = image_size.get_height
if width > height
self.ad_type = "horizontal"
else
self.ad_type = "vertical"
end
end
end

View File

@@ -1,7 +1,6 @@
<%= simple_form_for @advertisement, :html => {:multipart => true} do |f| %>
<%= f.input :file, :as => :file %>
<%= f.input :referral_url %>
<%= f.input :ad_type, :collection => %w(vertical horizontal) %>
<%= f.input :referral_url, :as => :string %>
<%= f.input :status, :collection => %w(active inactive) %>
<%= f.button :submit %>
<%= f.button :submit, "Submit" %>
<% end %>

View File

@@ -1,4 +1,4 @@
<% content_for(:secondary_nav_links) do %>
<% content_for(:secondary_links) do %>
<menu id="secondary-links">
<li><%= link_to "Listing", advertisements_path %></li>
<li><%= link_to "New", new_advertisement_path %></li>