Note that there are some explanatory texts on larger screens.

plurals
  1. POissue with mongoid and rails when do seed its faild
    text
    copied!<p>first is the status:</p> <pre><code>class Status include Mongoid::Document field :name, type: String has_one :Apis validates_presence_of :name end </code></pre> <p>as well have APIS:</p> <pre><code>class Apis include Mongoid::Document field :name, type: String field :description, type: String, default: '' field :create_at, type: DateTime, default: -&gt;{ DateTime.now } belongs_to :Status validates_presence_of :name end </code></pre> <p>the SEED file:</p> <pre><code># This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) if Status.count == 0 Status.create({name: "active"}) Status.create({name: "inactive"}) Status.create({name: "pending"}) Status.create({name: "rejected"}) Status.create({name: "sending"}) Status.create({name: "contentItemPending"}) Status.create({name: "contentItemListed"}) Status.create({name: "staticItemListed"}) Status.create({name: "requestItemPending"}) end if Apis.count == 0 active_status = Status.find_by({name:"active"}) youtub = Apis.new({name:"youtube", description:"Youtube API Used youtube_it gem"}) youtub.build_Status(active_status.id) youtub.save! itunes = Apis.new({name:"itunes", description:"ITUNES API Used itunes gem"}) itunes.build_Status(active_status.id) itunes.save! factual = Apis.new({name:"factual", description:"FACTUAL API Used FACTUAL gem"}) factual.build_Status(active_status.id) factual.save! end </code></pre> <p>now i get this error:</p> <pre><code>fastwings:Feelike-Agent/ (master✗) $ rake db:seed [14:21:41] rake aborted! uninitialized constant Statu /usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:230:in `block in constantize' /usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:229:in `each' /usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:229:in `constantize' /usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/core_ext/string/inflections.rb:54:in `constantize' /usr/local/rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.19/lib/mongoid/relations/metadata.rb:602:in `klass' /usr/local/rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.19/lib/mongoid/relations/builders.rb:68:in `block in builder' /home/fastwings/Projects/Ruby/Feelike-Agent/db/seeds.rb:23:in `&lt;top (required)&gt;' /usr/local/rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.19/lib/mongoid/railties/database.rake:13:in `block (2 levels) in &lt;top (required)&gt;' /usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval' /usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `&lt;main&gt;' Tasks: TOP =&gt; db:seed (See full trace by running task with --trace) </code></pre> <p>now i got no clue what i doing here wrong what is here not work???</p> <p>as well its make at line 23 means youtub.build_Status(active_status.id) to uninitialized constant Statu why???</p> <p>ok Guys its work my error was this: belongs_to :Status , class_name: 'something' and has_one :Apis ,class_name:'something' and the seeder need added like this:</p> <pre><code>Mongoid.purge! if SystemStatus.count == 0 SystemStatus.create!({name: "active"}) SystemStatus.create!({name: "inactive"}) SystemStatus.create!({name: "pending"}) SystemStatus.create!({name: "rejected"}) SystemStatus.create!({name: "sending"}) SystemStatus.create!({name: "contentItemPending"}) SystemStatus.create!({name: "contentItemListed"}) SystemStatus.create!({name: "staticItemListed"}) SystemStatus.create!({name: "requestItemPending"}) end if Providers.count == 0 active_status = SystemStatus.find_by({name:"active"}) Providers.create!({name:"youtube", description:"Youtube API Used youtube_it gem",status: active_status}) Providers.create!({name:"itunes", description:"Youtube API Used youtube_it gem",status: active_status}) Providers.create!({name:"youtube", description:"Youtube API Used youtube_it gem",status: active_status}) Providers.create!({name:"unknown", description:"Rest service conntection",status: active_status}) end </code></pre> <p>what that went wrong here was that it didnt know what class to go to as well how i enter the data</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload