Created
May 4, 2011 22:19
-
-
Save neiltron/956158 to your computer and use it in GitHub Desktop.
Sinatra/mongoid issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#removed a bunch of routes that aren't relevant | |
require 'rubygems' | |
require 'bundler' | |
require 'sinatra' | |
require 'haml' | |
require 'bson' | |
require 'models/user' | |
require 'models/monger' | |
#require 'models/location' | |
#require 'models/review' | |
require 'mongoid' | |
require 'yajl' | |
require 'oa-oauth' | |
class Burritowar < Sinatra::Base | |
set :app_file, __FILE__ | |
set :root, File.dirname(__FILE__) | |
set :server, 'thin' | |
Mongoid.configure do |config| | |
host = "localhost" | |
config.master = Mongo::Connection.new.db("burritowar") | |
end | |
get '/auth/:provider/callback' do | |
auth = request.env['omniauth.auth'] | |
time = Time.now.to_i | |
#following line produces this error: "ArgumentError - wrong number of arguments (1 for 0):" | |
user = User.new( :name => 'what', :nickname => 'what', :provider => 'twitter', :provider_id => 'what', :last_update => 'never' ) | |
user.save | |
session[:uid] = auth['uid'] | |
session[:name] = auth['user_info']['nickname'] | |
if session[:redirect] | |
redirect session[:redirect] | |
session.delete('redirect') | |
else | |
redirect '/' | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongoid' | |
class User | |
include Mongoid::Document | |
field :name, :type => String | |
field :nickname, :type => String | |
field :provider, :type => String | |
field :provider_id, :type => String | |
field :last_update, :type => String | |
#references_many :reviews, :stored_as => 'hash' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment