set up explore controller routes and rename methods

This commit is contained in:
Devin Howard 2016-09-23 17:07:06 +08:00
parent 686d80e274
commit 5e180ac10e
2 changed files with 14 additions and 12 deletions

View file

@ -9,7 +9,7 @@ class ExploreController < ApplicationController
#autocomplete :map, :name, full: true, extra_data: [:user_id] #autocomplete :map, :name, full: true, extra_data: [:user_id]
# GET /explore/active # GET /explore/active
def activemaps def active
page = params[:page].present? ? params[:page] : 1 page = params[:page].present? ? params[:page] : 1
@maps = policy_scope(Map).order('updated_at DESC') @maps = policy_scope(Map).order('updated_at DESC')
.page(page).per(20) .page(page).per(20)
@ -25,7 +25,7 @@ class ExploreController < ApplicationController
end end
# GET /explore/featured # GET /explore/featured
def featuredmaps def featured
page = params[:page].present? ? params[:page] : 1 page = params[:page].present? ? params[:page] : 1
@maps = policy_scope( @maps = policy_scope(
Map.where('maps.featured = ? AND maps.permission != ?', Map.where('maps.featured = ? AND maps.permission != ?',
@ -39,7 +39,7 @@ class ExploreController < ApplicationController
end end
# GET /explore/mine # GET /explore/mine
def mymaps def mine
unless authenticated? unless authenticated?
skip_policy_scope skip_policy_scope
return redirect_to explore_active_path return redirect_to explore_active_path
@ -57,7 +57,7 @@ class ExploreController < ApplicationController
end end
# GET /explore/shared # GET /explore/shared
def sharedmaps def shared
unless authenticated? unless authenticated?
skip_policy_scope skip_policy_scope
return redirect_to explore_active_path return redirect_to explore_active_path
@ -75,7 +75,7 @@ class ExploreController < ApplicationController
end end
# GET /explore/starred # GET /explore/starred
def starredmaps def starred
unless authenticated? unless authenticated?
skip_policy_scope skip_policy_scope
return redirect_to explore_active_path return redirect_to explore_active_path
@ -94,7 +94,7 @@ class ExploreController < ApplicationController
end end
# GET /explore/mapper/:id # GET /explore/mapper/:id
def usermaps def mapper
page = params[:page].present? ? params[:page] : 1 page = params[:page].present? ? params[:page] : 1
@user = User.find(params[:id]) @user = User.find(params[:id])
@maps = policy_scope(Map.where(user: @user)) @maps = policy_scope(Map.where(user: @user))

View file

@ -57,12 +57,14 @@ Metamaps::Application.routes.draw do
post 'maps/:id/star', to: 'maps#star', defaults: { format: :json } post 'maps/:id/star', to: 'maps#star', defaults: { format: :json }
post 'maps/:id/unstar', to: 'maps#unstar', defaults: { format: :json } post 'maps/:id/unstar', to: 'maps#unstar', defaults: { format: :json }
get 'explore/active', to: 'maps#activemaps' namespace :explore do
get 'explore/featured', to: 'maps#featuredmaps' get 'active'
get 'explore/mine', to: 'maps#mymaps' get 'featured'
get 'explore/shared', to: 'maps#sharedmaps' get 'mine'
get 'explore/starred', to: 'maps#starredmaps' get 'shared'
get 'explore/mapper/:id', to: 'maps#usermaps' get 'starred'
get 'mapper/:id', action: 'mapper'
end
devise_for :users, skip: :sessions, controllers: { devise_for :users, skip: :sessions, controllers: {
registrations: 'users/registrations', registrations: 'users/registrations',