Skip to content

Commit

Permalink
- welcome screen at root route
Browse files Browse the repository at this point in the history
- using assignments index to replace the all route
  • Loading branch information
yasonk committed May 11, 2015
1 parent 1c0f230 commit 7dd94bf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
11 changes: 5 additions & 6 deletions app/controllers/support_assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ class SupportAssignmentsController < ApplicationController
# GET /support_assignments
# GET /support_assignments.json
def index
@support_assignments = SupportAssignment.where(user_id: params[:user_id]).order :date
if params[:user_id].present?
@support_assignments = SupportAssignment.where(user_id: params[:user_id]).order :date
else
@support_assignments = SupportAssignment.all.order :date
end
end

# GET /support_assignments/1
Expand Down Expand Up @@ -66,11 +70,6 @@ def today
render :show
end

def all
@support_assignments = SupportAssignment.all.order :date
render :index
end

def month
@support_assignments = SupportAssignment.where("strftime('%m', date) + 0 = ?", params[:month].to_i).order :date
render :index
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/support_assignments_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def new_assignment_link
if params[:user_id].present?
link_to('New Support assignment', new_user_support_assignment_path)
else
link_to('New Support assignment', new_support_assignments_path)
link_to('New Support assignment', new_support_assignment_path)
end
end

Expand Down
7 changes: 7 additions & 0 deletions app/views/application/welcome.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<h1 style="text-align: center">Welcome To Support Hero</h1>
<p>Browse Users: <a href="/users">/users</a></p>
<p>Browse Duty Assignments: <a href="/support_assignments">/support_assignments</a></p>
</body>
</html>
6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
resources :support_assignments
end

resource :support_assignments, only: [:new, :create, :index] do
resources :support_assignments, only: [:new, :create, :index]
scope :support_assignments, :controller => 'support_assignments' do
get 'today'
get 'all'
get 'month/:month' => 'support_assignments#month'
end

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

# You can have the root of your site routed with "root"
# root 'welcome#index'
root 'application#welcome'

# Example of regular route:
# get 'products/:id' => 'catalog#view'
Expand Down

0 comments on commit 7dd94bf

Please sign in to comment.