Commit e6251075

mo k <m@mokhan.ca>
2012-02-08 04:22:45
add favorites page.
1 parent f361e64
Changed files (6)
app/controllers/profiles_controller.rb
@@ -14,4 +14,8 @@ class ProfilesController < ApplicationController
     @creations = current_user.creations.page(params[:page]).per(16)
   end
 
+  def favorites
+    @favorites = current_user.favorites
+    @creations = @favorites.map {|f| f.creation }
+  end
 end
app/views/creations/new.html.erb
@@ -4,6 +4,7 @@
 
 <ul class="tabs">
   <li> <%= link_to "Profile", profiles_mine_path %></li>
+  <li> <%= link_to "Favorites", profiles_favorites_path %></li>
   <li class="active"> <%= link_to "Share", new_creation_path %></li>
   <li> <%= link_to "Settings", edit_user_registration_path %> </li>
 </ul>
app/views/profiles/favorites.html.erb
@@ -0,0 +1,30 @@
+<% content_for :title do %>
+  My profile
+<% end %>
+
+<ul class="tabs">
+  <li> <%= link_to "Profile", profiles_mine_path %></li>
+  <li class="active"> <%= link_to "Favorites", profiles_favorites_path %></li>
+  <li> <%= link_to "Share", new_creation_path %></li>
+  <li> <%= link_to "Settings", edit_user_registration_path %> </li>
+</ul>
+
+<div class="row">
+  <div class="span4">
+    <div class="media-grid">
+      <a href="<%= url_for profile_path(current_user) %>"><img src="<%= avatar_url current_user %>&amp;s=200" alt="<%= current_user.name %>" /></a>
+    </div>
+    <h3><%= current_user.name %></h3>
+    <p>member since: <%= current_user.created_at.to_s :foomat %></p>
+    <p>last signed in: <%= current_user.last_sign_in_at.to_s :foomat %></p>
+    <a href="http://en.gravatar.com/" target="_blank">Change My Photo</a>
+  </div>
+  <div class="span12">
+    <h2>My Favorites</h2>
+    <ul class="media-grid">
+      <% @creations.each do |creation| %>
+        <li><a href="<%= url_for creation %>"><img class="thumbnail" src="<%= creation.image.thumb.url %>" alt="<%= creation.name %>"></a></li>
+      <% end %>
+    </ul>
+  </div>
+</div>
app/views/profiles/mine.html.erb
@@ -4,6 +4,7 @@
 
 <ul class="tabs">
   <li class="active"> <%= link_to "Profile", profiles_mine_path %></li>
+  <li> <%= link_to "Favorites", profiles_favorites_path %></li>
   <li> <%= link_to "Share", new_creation_path %></li>
   <li> <%= link_to "Settings", edit_user_registration_path %> </li>
 </ul>
app/views/registrations/edit.html.erb
@@ -3,6 +3,7 @@
 <% end %>
 <ul class="tabs">
   <li> <%= link_to "Profile", profiles_mine_path %></li>
+  <li> <%= link_to "Favorites", profiles_favorites_path %></li>
   <li> <%= link_to "Share", new_creation_path %></li>
   <li class="active"> <%= link_to "Settings", edit_user_registration_path %> </li>
 </ul>
config/routes.rb
@@ -19,6 +19,7 @@ Cake::Application.routes.draw do
   get "profiles/index"
   get "profiles/show"
   get "profiles/mine"
+  get "profiles/favorites"
   match 'profiles/show/:id' => 'profiles#show', :as => 'profile', :method => 'GET'
 
   # /search