automatically identify ad type
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 %>
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user