Skip to content

Instantly share code, notes, and snippets.

@abhishek0
Last active December 20, 2015 20:49
Show Gist options
  • Save abhishek0/6192766 to your computer and use it in GitHub Desktop.
Save abhishek0/6192766 to your computer and use it in GitHub Desktop.
Default users
rake aborted!
undefined method `<<' for nil:NilClass
/home/abhishek/mine/code/infocus/backend-ror/db/seeds.rb:10:in `(root)'
org/jruby/RubyKernel.java:1073:in `load'
/home/abhishek/.rvm/gems/jruby-1.7.4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:1:in `(root)'
/home/abhishek/.rvm/gems/jruby-1.7.4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/home/abhishek/.rvm/gems/jruby-1.7.4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/home/abhishek/.rvm/gems/jruby-1.7.4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
org/jruby/RubyProc.java:255:in `call'
/home/abhishek/.rvm/gems/jruby-1.7.4/bundler/gems/mongoid-85e146637503/lib/mongoid/railties/database.rake:18:in `(root)'
org/jruby/RubyArray.java:1617:in `each'
org/jruby/RubyArray.java:1617:in `each'
org/jruby/RubyKernel.java:1073:in `load'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
puts 'Default users'
admin = User.create! :first_name => 'admin', :last_name => 'admin', :email => 'admin@example.com', :mobile => '9999911111', :locality => 'Goregaon', :city => 'Mumbai', :user_type => 'admin', :username => 'admin@example.com', :password => 'admin'
franchisee = User.create! :first_name => 'franchisee', :last_name => 'franchisee', :email => 'franchisee@example.com', :mobile => '9999911111', :locality => 'Goregaon', :city => 'Mumbai', :user_type => 'franchisee', :username => 'franchisee@example.com', :password => 'franchisee'
#puts(admin.methods.grep(/child/))
admin.children<< franchisee
class User
include Mongoid::Document
store_in collection: "users"
validates :first_name,:last_name,:email,:mobile, presence: true
validates :locality,:city, presence: true
belongs_to :parent, :inverse_of => :children, class_name: "User"
has_many :children, :inverse_of => :parent, class_name: "User"
field :first_name, type: String
field :last_name, type: String
field :email, type: String
field :mobile, type: String
field :locality, type: String
field :city, type: String
field :address, type: String
field :blood_grp, type: String
field :emergency_no, type: String
field :user_type, type: String
field :dob, type: Integer
field :username, type: String
field :password, type: String
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment