From 77420bcb095dcf7b2323295804a4c60c0b4bc382 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 3 Nov 2012 13:45:08 -0400 Subject: [PATCH] made feedback and metamaps manual display conditional instead of hard coded so there's not errors on a blank database --- app/controllers/main_controller.rb | 2 +- app/controllers/sessions_controller.rb | 9 +++++++-- app/controllers/users_controller.rb | 9 +++++++-- app/views/layouts/application.html.erb | 2 +- config/.database.yml.swp | Bin 12288 -> 0 bytes 5 files changed, 16 insertions(+), 6 deletions(-) delete mode 100644 config/.database.yml.swp diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index fd44c546..a19e889b 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -11,7 +11,7 @@ class MainController < ApplicationController @maps = Map.visibleToUser(@current, nil) @map = @maps.sample - @mapjson = @map.self_as_json(@current).html_safe + @mapjson = @map.self_as_json(@current).html_safe if @map respond_to do |format| format.html { respond_with(@map, @user) } diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 29e638ea..f463429c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -23,9 +23,14 @@ class SessionsController < ApplicationController @user = User.new @connor = User.find(555629996) - @map = Map.find(5) + @map = Map.find(:first, 5) - respond_with(@user, @session, location: user_map_url(@connor,@map)) do |format| + if @map + respond_with(@user, @session, location: user_map_url(@connor,@map)) do |format| + end + else + respond_with(@user, @session, location: root_url) do |format| + end end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 821e3643..cd46ebd4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -40,9 +40,14 @@ class UsersController < ApplicationController # direct them straight to the metamaps manual map. @connor = User.find(555629996) - @map = Map.find(5) + @map = Map.find(:first, 5) - respond_with(@user, location: user_map_url(@connor,@map)) do |format| + if @map + respond_with(@user, location: user_map_url(@connor,@map)) do |format| + end + else + respond_with(@user, location: root_url) do |format| + end end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6fd8a97a..dc3a1260 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -65,7 +65,7 @@