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

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

View File

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

View File

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