Commit 5d040a51

mo k <mo@mokhan.ca>
2012-08-08 03:49:00
create the avatar controller.
1 parent dd648e4
Changed files (2)
app/controllers/avatars_controller.rb
@@ -0,0 +1,15 @@
+class AvatarsController < ApplicationController
+  before_filter :authenticate_user!
+
+  def create
+    @avatar = current_user.avatar.build(params[:avatar])
+
+    respond_to do |format|
+      if @avatar.save
+        format.html { redirect_to(current_user, :notice => 'Your new avatar has been uploaded.') }
+      else
+        flash[:error] = "could not upload photo"
+      end
+    end
+  end
+end
config/routes.rb
@@ -34,7 +34,9 @@ Cake::Application.routes.draw do
   get "search/index"
 
   # /users
-  devise_for :users, :controllers => {:registrations => 'registrations'}
+  devise_for :users, :controllers => {:registrations => 'registrations'} do
+    resources :avatars
+  end
   devise_for :user, :path => '', :path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "register" }
 
   # sitemap