Commit c736625

mo khan <mo@mokhan.ca>
2013-06-08 14:19:19
replace html img tags with rails image_tag to allow rails to serve static assets via a CDN
1 parent 6a74a83
Changed files (5)
app/views/cakes/index.html.erb
@@ -9,7 +9,7 @@
       <% @cakes.each do |cake| %>
         <div class="span3">
         <div class="thumbnail">
-          <a href="<%= url_for cake %>"><img src="<%= cake.photo.url(:thumb) %>" /></a>
+          <a href="<%= url_for cake %>"><%= image_tag @cake.photo.url(:thumb), alt: @cake.name %></a>
           <div class="caption">
             <h3><a href="<%= url_for cake %>"><%= cake.name %></a></h3>
             <p><a class="btn" href="<%= url_for cake %>">View</a></p>
app/views/cakes/show.html.erb
@@ -3,10 +3,7 @@
 
 <div class="row">
   <div class="span6">
-    <ul class="thumbnails">
-      <li class="span6">
-        <a class="thumbnail" href="<%= url_for cake_path(@cake) %>"><img src="<%= @cake.photo.url %>" alt="<%= @cake.name %>" /></a>
-      </li>
-    </ul>
+    <%= image_tag @cake.photo.url(:hero), alt: @cake.name, class: 'thumbnails' %>
   </div>
+  <div class="span6">&nbsp;</div>
 </div>
app/views/categories/show.html.erb
@@ -10,7 +10,7 @@
       <% @cakes.each do |cake| %>
         <div class="span3">
         <div class="thumbnail">
-          <a href="<%= url_for cake %>"><img src="<%= cake.photo.url(:thumb) %>" /></a>
+          <a href="<%= url_for cake %>"><%= image_tag @cake.photo.url(:thumb), alt: @cake.name %></a>
           <div class="caption">
             <h3><a href="<%= url_for cake %>"><%= cake.name %></a></h3>
             <p><a class="btn" href="<%= url_for cake %>">View</a></p>
config/environments/development.rb
@@ -34,4 +34,5 @@ Confection::Application.configure do
 
   # Expands the lines which load the assets
   config.assets.debug = true
+  config.action_controller.asset_host = ENV['ASSET_HOST']
 end
config/environments/production.rb
@@ -43,7 +43,7 @@ Confection::Application.configure do
   # config.cache_store = :mem_cache_store
 
   # Enable serving of images, stylesheets, and JavaScripts from an asset server
-  # config.action_controller.asset_host = "http://assets.example.com"
+  config.action_controller.asset_host = ENV['ASSET_HOST']
 
   # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
   # config.assets.precompile += %w( search.js )