Commit 4564f653

mo k <mo@mokhan.ca>
2012-05-10 13:45:50
when adding a favorite the user id was not getting saved.
1 parent adc04f4
Changed files (3)
app
models
views
config
app/models/user.rb
@@ -12,7 +12,7 @@ class User < ActiveRecord::Base
       favorites.find { |favorite| favorite.user == self }
     else
       logger.info 'add creation'
-      creation.favorites.create({:user => self})
+      creation.favorites.create({:user_id => self.id})
     end
   end
 
app/views/favorites/index.html.erb
@@ -12,7 +12,9 @@
   <div class="span16">
     <ul class="media-grid">
       <% @creation.favorites.each do |favorite| %>
-        <a href="<%= url_for profile_path(favorite.user) %>"><img src="<%= avatar_url favorite.user %>&amp;s=200" alt="<%= favorite.user.name %>" /></a>
+        <a href="<%= url_for profile_path(favorite.user) %>">
+          <img src="<%= avatar_url favorite.user %>&amp;s=200" alt="<%= favorite.user.name %>" />
+        </a>
       <% end %>
     </ul>
   </div>
config/routes.rb
@@ -20,23 +20,22 @@ Cake::Application.routes.draw do
 
   # /profiles
   get "profiles/index"
-  get "profiles/show"
-  get "profiles/mine"
   get "profiles/favorites"
-  match 'profiles/show/:id' => 'profiles#show', :as => 'profile', :method => 'GET'
+  match 'profiles/:id' => 'profiles#show', :as => 'profile', :method => 'GET'
+  #match 'profiles/show/:id' => 'profiles#show', :as => 'profile', :method => 'GET'
   match 'profiles/mine' => 'profiles#mine', :as => 'user_root', :method => 'GET'
 
-  # /search
-  get "search/index"
-
   # /artists
   match 'artists' => 'profiles#index', :as => 'all_profiles', :method => 'GET'
-  match 'artists/:id' => 'profiles#show', :as => 'profile', :method => 'GET'
+  match 'artists/:id' => 'profiles#show', :as => 'artist', :method => 'GET'
 
   # /categories
   match 'categories/:id' => 'categories#show', :method => 'GET'
   get 'categories/show'
 
+  # /search
+  get "search/index"
+
   # /users
   devise_for :users, :controllers => {:registrations => 'registrations'}