Skip to content

Instantly share code, notes, and snippets.

View abhishek0's full-sized avatar

Abhishek Sharma abhishek0

  • Snapstick Inc.
View GitHub Profile
@abhishek0
abhishek0 / seed.rb
Created August 9, 2013 09:38
Many to one on same mongoid collection
admin = User.create! :first_name => 'admin', :last_name => 'admin', :email => '[email protected]', :mobile => '9999911111', :locality => 'Goregaon', :city => 'Mumbai', :user_type => 'admin', :username => '[email protected]', :password => 'admin'
franchisee = User.create! :first_name => 'franchisee', :last_name => 'franchisee', :email => '[email protected]', :mobile => '9999911111', :locality => 'Goregaon', :city => 'Mumbai', :user_type => 'franchisee', :username => '[email protected]', :password => 'franchisee'
franchisee.parent = admin
franchisee.save!
class ApplicationController < ActionController::Base
before_action :require_login
private
def check_user
if not request.headers["user_id"].empty?
def self.get_user
Users.get({id => request.headers["user_id"]})
end
@abhishek0
abhishek0 / request
Created August 8, 2013 19:33
Simple mongoid models and creation controllers
curl http://localhost:3000/users -d "{'user': {'firstName': 'Abhishek', 'loginInfo':{'password':'p'}}}"