Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:sakomoko/Eretheal

Conflicts:
	app/controllers/application_controller.rb
  • Loading branch information...
commit 1d3db192171f0dc01f7b9376a89268eda407ec2e 2 parents 6419f34 + 6851e63
sakomoko authored
15 Gemfile.lock
View
@@ -29,6 +29,7 @@ GEM
activesupport (= 3.1.3)
activesupport (3.1.3)
multi_json (~> 1.0)
+ archive-tar-minitar (0.5.2)
arel (2.2.1)
bcrypt-ruby (3.0.1)
bson (1.5.2)
@@ -58,7 +59,6 @@ GEM
orm_adapter (~> 0.0.3)
warden (~> 1.1)
diff-lcs (1.1.3)
- dynamic_form (1.1.4)
erubis (2.7.0)
execjs (1.2.13)
multi_json (~> 1.0)
@@ -113,18 +113,6 @@ GEM
mongoid (~> 2.0)
multi_json (1.0.4)
nokogiri (1.5.0)
-<<<<<<< HEAD
- oauth (0.4.5)
- oauth-plugin (0.4.0.rc2)
- multi_json
- oauth (~> 0.4.4)
- oauth2
- rack
- oauth2 (0.5.2)
- faraday (~> 0.7)
- multi_json (~> 1.0)
-=======
->>>>>>> parent of 77988f8... add oauth-plugin
orm_adapter (0.0.5)
polyglot (0.3.3)
rack (1.3.6)
@@ -223,7 +211,6 @@ DEPENDENCIES
coffee-rails (~> 3.1.0.rc)
database_cleaner
devise
- dynamic_form
factory_girl_rails
growl
guard
2  app/controllers/api/characters_controller.rb
View
@@ -0,0 +1,2 @@
+class CharactersController < ApplicationController
+end
8 app/controllers/api/positions_controller.rb
View
@@ -0,0 +1,8 @@
+class Api::PositionsController < ApplicationController
+ before_filter :login_or_oauth_required
+ respond_to :json, :xml
+ def show
+ @character = current_character
+ respond_with @character, include: :user
+ end
+end
15 app/controllers/application_controller.rb
View
@@ -1,3 +1,18 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+ alias :login_required :authenticate_user!
+ alias :logged_in? :user_signed_in?
+
+ def current_user=(user)
+ sign_in(user)
+ end
+
+ def current_character
+ return @character if @character
+ if session[:character_id]
+ @character = current_user.characters.find(session[:character_id])
+ elsif current_token
+ @character = current_token.character
+ end
+ end
end
15 app/controllers/characters_controller.rb
View
@@ -0,0 +1,15 @@
+class CharactersController < ApplicationController
+ before_filter :login_or_oauth_required
+ respond_to :html, :json, :xml
+
+ def index
+ @characters = current_user.characters
+ respond_with @characters
+ end
+
+ def select
+ @character = current_user.characters.find(params[:id])
+ session[:character_id] = @character.id
+ respond_with @character
+ end
+end
5 app/models/position.rb
View
@@ -22,4 +22,9 @@ def renew(field)
end
end
+ def serializable_hash(options=nil)
+ options ||= {}
+ super(options.reverse_merge({ :include => :field, :methods => :area }))
+ end
+
end
3  config/mongoid.yml
View
@@ -1,7 +1,7 @@
development:
host: localhost
database: eretheal_development
-
+ identity_map_enabled: true
test:
host: localhost
database: eretheal_test
@@ -13,6 +13,7 @@ production:
username: <%= ENV['MONGOID_USERNAME'] %>
password: <%= ENV['MONGOID_PASSWORD'] %>
database: <%= ENV['MONGOID_DATABASE'] %>
+ identity_map_enabled: true
# slaves:
# - host: slave1.local
# port: 27018
11 config/routes.rb
View
@@ -59,4 +59,15 @@
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
+
+ namespace "api" do
+ resource :position, only: ["show"]
+ put "position/:id", action: "update"
+ end
+
+ resources :characters, :only =>["index"] do
+ member do
+ get :select
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.