Commit 959bd343

mo khan <mo@mokhan.ca>
2014-05-22 04:00:04
move dashboard to my/dashboard.
1 parent 802e38c
app/controllers/my/dashboard_controller.rb
@@ -0,0 +1,8 @@
+module My
+  class DashboardController < BaseController
+    def index
+      @items = (current_user.creations + current_user.tutorials).sort_by! { |x| x.created_at }.reverse
+      @activities = current_user.recent_activities
+    end
+  end
+end
app/controllers/dashboard_controller.rb
@@ -1,8 +0,0 @@
-class DashboardController < ApplicationController
-  before_filter :authenticate_user!
-
-  def index
-    @items = (current_user.creations + current_user.tutorials).sort_by! { |x| x.created_at }.reverse
-    @activities = current_user.recent_activities
-  end
-end
app/controllers/tutorials_controller.rb
@@ -24,7 +24,7 @@ class TutorialsController < ApplicationController
     @tutorial = current_user.tutorials.create(tutorial_params)
     current_user.tag(@tutorial, :with => params[:tutorial_tags], :on => :tags)
     if @tutorial.save
-      redirect_to dashboard_path, :notice => t(:tutorial_saved)
+      redirect_to my_dashboard_path, :notice => t(:tutorial_saved)
     else
       flash[:error] = @tutorial.errors.full_messages
       render :new
@@ -44,7 +44,7 @@ class TutorialsController < ApplicationController
   def destroy
     @tutorial = current_user.tutorials.find(params[:id])
     @tutorial.destroy
-    redirect_to dashboard_path
+    redirect_to my_dashboard_path
   end
 
   def tutorial_params
app/views/layouts/_header.html.erb
@@ -79,7 +79,7 @@
           <li class="divider-vertical hidden-phone"></li>
           <% if user_signed_in? %>
           <li>
-            <%= link_to dashboard_path do %>
+            <%= link_to my_dashboard_path do %>
               <%= avatar_for(current_user, size: 24) %>
             <% end %>
           </li>
app/views/dashboard/_creation.html.erb → app/views/my/dashboard/_creation.html.erb
File renamed without changes
app/views/dashboard/_tutorial.html.erb → app/views/my/dashboard/_tutorial.html.erb
File renamed without changes
app/views/dashboard/index.html.erb → app/views/my/dashboard/index.html.erb
File renamed without changes
app/views/notification_mailer/notification_email.html.erb
@@ -6,7 +6,7 @@
   <body>
     <h1>Hi <%= @user.name %>,</h1>
     <p>
-    You have new notification. Click <%= link_to "here", dashboard_url %> to see.
+    You have new notification. Click <%= link_to "here", my_dashboard_url %> to see.
     </p>
     <p>Have a wonderful day!</p>
   </body>
app/views/notification_mailer/notification_email.text.erb
@@ -1,6 +1,6 @@
 
 Hi <%= @user.name %>,
 
-You have new notification. Click <%= link_to "here", dashboard_url %> to see.
+You have new notification. Click <%= link_to "here", my_dashboard_url %> to see.
 
 Have a wonderful day!
app/views/photos/_form.html.erb
@@ -19,7 +19,7 @@
       <div class="span10">&nbsp;</div>
       <div class="span2">
         <span class="btn btn-success fileinput-button"><i class="icon-plus icon-white"></i><span> Browse... </span><%= f.file_field :image %></span>
-        <%= link_to "NEXT", dashboard_path, :class => "btn btn-primary" %>
+        <%= link_to "NEXT", my_dashboard_path, :class => "btn btn-primary" %>
       </div>
     </div>
     <div class="fileupload-loading"></div>
app/views/shared/_account_nav.html.erb
@@ -1,7 +1,7 @@
 <div class="row">
   <div class="span12">
     <ul class="nav nav-tabs">
-      <li class="<%= selected == :dashboard ? "active" : "" %>"><%= link_to "Dashboard", dashboard_path %></li>
+      <li class="<%= selected == :dashboard ? "active" : "" %>"><%= link_to "Dashboard", my_dashboard_path %></li>
       <li class="<%= selected == :creations ? "active" : "" %>"><%= link_to "Creations", my_cakes_path %></li>
       <li class="<%= selected == :favorites ? "active" : "" %>"><%= link_to "Favorites", profiles_favorites_path %></li>
       <li class="<%= selected == :basic_info ? "active" : "" %>"><%= link_to "Settings", settings_path %></li>
config/routes.rb
@@ -3,7 +3,6 @@ Cake::Application.routes.draw do
   get "about_us" => "home#about_us"
   get "why_cakeside" => "home#why_cakeside"
 
-  get 'dashboard', to: 'dashboard#index'
   post 'comments', to: 'comments#create'
 
   resources :tutorials do
@@ -68,6 +67,7 @@ Cake::Application.routes.draw do
   end
 
   namespace :my do
+    get 'dashboard', to: 'dashboard#index'
     resources :cakes do
     end
   end
spec/controllers/dashboard_controller_spec.rb → spec/controllers/my/dashboard_controller_spec.rb
@@ -1,6 +1,6 @@
 require "spec_helper"
 
-describe DashboardController do
+describe My::DashboardController do
   context "#index" do
     let(:user) { create(:user) }
     let!(:activity) { create(:activity, user: user) }
spec/controllers/tutorials_controller_spec.rb
@@ -72,7 +72,7 @@ describe TutorialsController do
       end
 
       it "redirects to the created tutorial" do
-        response.should redirect_to(dashboard_path)
+        response.should redirect_to(my_dashboard_path)
       end
     end
 
@@ -147,7 +147,7 @@ describe TutorialsController do
     end
 
     it "redirects to the tutorials list" do
-      response.should redirect_to(dashboard_path)
+      response.should redirect_to(my_dashboard_path)
     end
   end
 end