summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/switchboard_entries_controller.rb13
-rw-r--r--app/controllers/switchboards_controller.rb13
2 files changed, 24 insertions, 2 deletions
diff --git a/app/controllers/switchboard_entries_controller.rb b/app/controllers/switchboard_entries_controller.rb
index ef6c72e..32ca9bb 100644
--- a/app/controllers/switchboard_entries_controller.rb
+++ b/app/controllers/switchboard_entries_controller.rb
@@ -8,8 +8,17 @@ class SwitchboardEntriesController < ApplicationController
end
def show
- @switchboard_entry = @switchboard.switchboard_entries.find(params[:id])
- spread_breadcrumbs
+ if @switchboard
+ @switchboard_entry = @switchboard.switchboard_entries.find(params[:id])
+ spread_breadcrumbs
+ else
+ @switchboard_entry = SwitchboardEntry.find(params[:id])
+ end
+
+ respond_to do |format|
+ format.html
+ format.json { render json: @switchboard_entry }
+ end
end
def new
diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb
index c499c69..8ceb96d 100644
--- a/app/controllers/switchboards_controller.rb
+++ b/app/controllers/switchboards_controller.rb
@@ -3,8 +3,16 @@ class SwitchboardsController < ApplicationController
authorize_resource :switchboard, :through => :user
def index
+ if @user.nil?
+ @user = current_user
+ end
@switchboards = @user.switchboards
spread_breadcrumbs
+
+ respond_to do |format|
+ format.html
+ format.json { render json: @switchboards }
+ end
end
def show
@@ -14,6 +22,11 @@ class SwitchboardsController < ApplicationController
@switchboard = @user.switchboards.find(params[:id])
@switchboard_entries = @switchboard.switchboard_entries
spread_breadcrumbs
+
+ respond_to do |format|
+ format.html
+ format.json { render json: @switchboard }
+ end
end
def new