Commit d07feb75

mo k <mo@mokhan.ca>
2012-03-01 03:42:40
display first 25 characters of title in listing page.
1 parent 104c7cb
Changed files (2)
app/helpers/creations_helper.rb
@@ -1,2 +1,9 @@
 module CreationsHelper
+  def short_name(creation, length)
+    if( creation.name.length > length)
+      creation.name.split(//).first(length).join('') + '...'
+    else
+      creation.name
+    end
+  end
 end
app/views/shared/_creation_image_gallery.html.erb
@@ -3,7 +3,7 @@
     <li class="span3">
     <div class="thumbnail">
       <div class="caption">
-        <h5><%= creation.name.split[0...4].join(' ') %></h5>
+        <h5><a href="<%= url_for creation %>"><%= short_name(creation, 25) %></a></h5>
         <h6><a href="<%= url_for profile_path(creation.user) %>"><%= creation.user.name %></a></h6>
         <a href="<%= url_for creation %>">
           <img src="<%= creation.image.thumb.url %>" alt="<%= creation.name %>" width="260px" height="180px" />