Code Monkey home page Code Monkey logo

mongoid-site's Introduction

Documentation

These are the source files that power mongoid.org. It is a middleman powered static page.

Contributing

Please help Mongoid flesh out its documentation. We'll merge in any reasonable extensions to our website docs, and give credit for your help!

How to run the site locally

Clone this repo and run bundle install. Then run bundle exec middleman to start the server at http://localhost:4567

How to deploy a new version of mongoid.org

Clone the 'mongoid.github.io' submodule: git submodule init; git submodule update Then run bundle exec rake, to build the html version of the site. Commit and push the submodule: cd build; git commit -am'Update website'; git push origin master

Notes

All pages are written in haml, and for consistency must stay that way.

mongoid-site's People

Contributors

arthurnn avatar arunagw avatar bowsersenior avatar brahmana avatar cgriego avatar durran avatar dznz avatar etehtsea avatar ethangunderson avatar gjnoonan avatar lucke84 avatar matsimitsu avatar mscottford avatar ndbroadbent avatar niels avatar patcito avatar phoffer avatar piotrj avatar rmm5t avatar rspeicher avatar ryanong avatar s01ipsist avatar sauy7 avatar shwetakale avatar sukeerthiadiga avatar tiagogodinho avatar tilo avatar timoschilling avatar tomk32 avatar vickash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongoid-site's Issues

Self referential relationship through an embedded document causes error

I've battled with this all day and haven't come up with a solution. I dug through the mongoid code and just couldn't come up with it.

I have the following arrangement
User embeds_many :relationships
Relationship references_one :user

Calling user.relationships.build(:user => other_user) causes the following error...
lib/mongoid/attributes.rb:199:in method_missing': undefined methodeach' for #Relationship:0x00000100a915b8 (NoMethodError)

I was unable to come up with a solution, but have provided code to reproduce the problem here...
https://gist.github.com/92de25900681cd82a63e

Update queries against references_many with stored_as don't push $push or $pull

With the following models...

class User
  include Mongoid::Document
  include Mongoid::Timestamps

class Post
  include Mongoid::Document
  include Mongoid::Timestamps    
  references_many :users, :stored_as => Array

Running the following code...

user = User.create
post = Post.create
post.users << user

Produces the following MongoDB query...

MONGODB test_development['posts'].update({"_id"=>BSON::ObjectId('4d1c36ab73036a6b02000002')}, {"$set"=>{"updated_at"=>Thu Dec 30 07:39:38 UTC 2010, "user_ids"=>[BSON::ObjectId('4d17f5d573036a0b6b00000a')]}})

Shouldn't this query be using $push and $pull to manipulate the array instead of using $set to overwrite its contents?

In the actual scenario where I'm using Mongoid, there exists the potential for the users_id array to be updated multiple times, and in effect this query that is generated runs the risk of losing changes to the user_ids array during a fast moving session.

Or, am I doing this wrong?

Documentation for recommended manual link between mappers

I'm creating this issue as requested by durran here.

Because support for associations between models that use Mongoid and those that use ActiveRecord will be taken out, it would be great to have some documentation on recommended ways to create manual links between mappers.

Indexes not Created

Hi, I am running the following:

Rails 3.0.0.rc
Mongo 1.6.2
mongoid 2.0.0.beta.17

I defined the following indexes in my model as follows:

class Job
  include Mongoid::Document
   ...
  field :inprogress,      :type => Boolean, :default => false
  field :undone,          :type => Boolean, :default => false
  field :created_at,      :type => Time

  index :inprogress
  index :undone
  index :created_at
  ...
end

And ran rake db:create_indexes

This is what mongo shows me my indexes are:

db.jobs.getIndexes()
[
{
"name" : "id",
"ns" : "my_db.jobs",
"key" : {
"_id" : 1
}
}
]

It looks like mongoid is not picking up the indexes I defined according to the instructions here: http://mongoid.org/docs/indexing/

Have any ideas?

rails generate mongoid:config

This part on the installation page it out of date

Executing this will add the following to the top of your config/application.rb, as well as switching your default ORM to Mongoid (i.e. rails g model will now generate Mongoid Documents as your models):
require 'mongoid/railtie'

The config generator only generates the config/mongoid.yml file now and requiring the railtie manually is no longer necessary, and the ORM is switched automatically unless explicitly overridden.

Explain that scopes are evaluated at load time

A lot of people on the mailing list don't realize that this:

scope :current, :where => { :start_date.lte => Date.today }

will evaluate Date.today when the class is loaded, rather than every time the scope is used.

The documentation should explain the correct way to implement this type of criteria in a scope. IE:

scope :current, lambda { :where => { :start_date.lte => Date.today } }

Remove design opinion from associations docs

http://mongoid.org/docs/associations/

The opening paragraph makes a statement which I feel is misleading and in Mongo's case somewhat inaccurate:

"Relational associations to documents in other collections are not handled by these macros, as it is against the general reasoning for choosing to use a non-relational data store."

The last clause could be left out. Embedding vs. not embedding is a design decision based on data size/use - there's no right or wrong answer.

Perhaps just:

"Relational associations to documents in other collections are not handled by these macros. Please see the Relational associations below."

This would also remove the last semi-valid objection on the mongodb.org Wiki against mongoid.

Setting a protected attribute through mass assignment does not raise an error

In mongoid-site / views / docs / documents / access.html.haml it says that "# Attempt to set attributes a person, raising an error." Setting a protected attribute through mass assignment does not raise an error. Instead, it silently ignores the assignment which is consistent with ActiveRecord. Although I wish the interface of protected attributes actually did raise an error when one was set this is not how it works and would break backward compatibility.

Also, the code examples on the access.html.haml page defines a User class but then later refers to it as "Person".

Strange behavior of references in MongoDB

I have posted my problem on StackOverflow http://stackoverflow.com/questions/5150242/strange-behavior-of-references-in-mongodb but still have no any response (though just a few hours)

I have two documents:

class MyUser
  include Mongoid::Document

  field ......

  references_many :statuses, :class_name => "MyStatus"
end

class MyStatus
  include Mongoid::Document

  field ......

  referenced_in :user, :class_name => "MyUser"
end

The problem is, I can get the user of any given status, but I cannot get the list of statuses from a user!

ie.

status = MyStatus.first
status.user # the output is correct here

user = MyUser.first
user.statuses # this one outputs [] instead of the list of statuses...

I want to know if this is a mongoid's known issue or just I have did something wrongly? Please help!

Clarity on dynamic fields type support

The dynamic fields documentation should clarify what types are supported. Specifically, BigDecimal, Date and DateTime should be mentioned since they are supported as declared types but not as dynamics.

Undocumented method "distinct"

There is an undocumented method "distinct", for example:

class Foo
  include Mongoid::Document
  field :name
end

# ....persist some documents....

Foo.criteria.distinct :name

I'll try to write some of these in a pull request when I get some time, as 3 of the current issues are mine.... But I'm quite swamped at the moment. If you get to them first, then that's even better.

Thanks once again

ArgumentError at / invalid byte sequence in UTF-8

I do not know if this is right place to seek help but I had the following problem:

ArgumentError at /
invalid byte sequence in UTF-8

Ruby /home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/data_sources/filesystem.rb: in =~, line 242
Web GET 192.168.1.104/
Jump to:
GETPOSTCookiesENV
Traceback (innermost first)

/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/data_sources/filesystem.rb: in =~
if data !~ /\A-{3,5}\s_$/...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/data_sources/filesystem.rb: in !~
if data !~ /\A-{3,5}\s_$/...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/data_sources/filesystem.rb: in parse
if data !~ /\A-{3,5}\s*$/...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/data_sources/filesystem.rb: in block in load_objects
content_filename, meta_filename, kind)...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/data_sources/filesystem.rb: in each
all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext)|...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/data_sources/filesystem.rb: in map
all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext)|...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/data_sources/filesystem.rb: in load_objects
all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext)|...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/data_sources/filesystem.rb: in items
load_objects('content', 'item', Nanoc3::Item)...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/base/site.rb: in block in load_items
items_in_ds = ds.items...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/base/site.rb: in each
data_sources.each do |ds|...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/base/site.rb: in load_items
data_sources.each do |ds|...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/base/site.rb: in load_data
load_items...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/extra/auto_compiler.rb: in build_site
@site.load_data...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/extra/auto_compiler.rb: in block in call
build_site...
internal:prelude: in synchronize
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.6/lib/nanoc3/extra/auto_compiler.rb: in call
@mutex.synchronize do...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/showexceptions.rb: in call
@app.call(env)...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/commonlogger.rb: in call
status, header, body = @app.call(env)...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/content_length.rb: in call
status, headers, body = @app.call(env)...
/home/user/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/handler/webrick.rb: in service
status, headers, body = @app.call(env)...
/home/user/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb: in service
si.service(req, res)...
/home/user/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb: in run
server.service(req, res)...
/home/user/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/server.rb: in block in start_thread
block ? block.call(sock) : run(sock)...
Request information

GET
No GET data.
POST
No POST data.
COOKIES
No cookie data.
Rack ENV
Variable Value
GATEWAY_INTERFACE
CGI/1.1
HTTP_ACCEPT
application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5
HTTP_ACCEPT_CHARSET
ISO-8859-1,utf-8;q=0.7,*;q=0.3
HTTP_ACCEPT_ENCODING
gzip,deflate,sdch
HTTP_ACCEPT_LANGUAGE
pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4
HTTP_CACHE_CONTROL
max-age=0
HTTP_CONNECTION
keep-alive
HTTP_HOST
192.168.1.104:3000
HTTP_IF_MODIFIED_SINCE
Tue, 04 Jan 2011 22:50:23 GMT
HTTP_USER_AGENT
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10
HTTP_VERSION
HTTP/1.1
PATH_INFO
/
QUERY_STRING
REMOTE_ADDR
192.168.1.105
REMOTE_HOST
192.168.1.105
REQUEST_METHOD
GET
REQUEST_PATH
/
REQUEST_URI
http://192.168.1.104:3000/
SCRIPT_NAME
SERVER_NAME
192.168.1.104
SERVER_PORT
3000
SERVER_PROTOCOL
HTTP/1.1
SERVER_SOFTWARE
WEBrick/1.3.1 (Ruby/1.9.2/2010-08-18)
nanoc.stack
[]
rack.errors

IO:

rack.input

StringIO:0x90377b8

rack.multiprocess
false
rack.multithread
true
rack.request.query_hash
{}
rack.request.query_string
rack.run_once
false
rack.url_scheme
http
rack.version
[1, 1]

Document 1-sided HABTM relation

The documentation should explain how to create 1-sided HABTM relations. Eg:

class Post
  include Mongoid::Document
  has_and_belongs_to_many :tags, :inverse_of => nil
end

class Tag
  include Mongoid::Document
  has_many :posts
end

400 instead of 404 in Railties

I was going to "Fork & Edit", but the button was broken. This is a simple change, however:

On the docs/rails/railties doc page, it says that the error Mongoid::Errors::DocumentNotFound will render a 400 status page. Looking at the code shows that the status will be :not_found (e.g. 404).

The change is thus:

- %li <tt>Mongoid::Errors::DocumentNotFound</tt>: 400
+ %li <tt>Mongoid::Errors::DocumentNotFound</tt>: 404

(views/docs/rails/railties.html.haml, line 43)

Document "critical" differences between Mongoid and ActiveRecord

Based on this Mongoid issue: https://github.com/mongoid/mongoid/issues/1071#issuecomment-1622197 (see comment by Durran)

Mongoid documentation should (probably) include a "Differences from ActiveRecord" section that enumerates differences between ActiveRecord and Mongoid despite very similar APIs.

The most obvious ones are "Child relations aren't saved automatically" and "Doesn't trigger child relation callbacks on save / update."

There's probably more than that?

Changing models status after persisting embedded objects

Hello,

I'd like to share a problem we are finding while testing a simple association.
First our models:

class Plan 
  include Mongoid::Document
  field :title
  field :Objective
  embeds_many :milestones
end

class Milestone
  include Mongoid::Document
  field :title, :type => String
  field :description, :type => String
  field :due, :type => Date
  embedded_in :Plan, :inverse_of => :milestones
end

Well, I'm creating a spec class to test the relationship:

it "should allow to add milestones" do
    milestone = Milestone.new(:title => "milestone 1")
    milestone.persisted?.should be false
    plan = Plan.new(:milestones => [milestone])
    plan.milestones[0].persisted?.should be false
    plan.save!.should be true
    plan.milestones.size.should be 1
    plan.milestones.should include milestone
    plan.milestones[0].persisted?.should be true
  end

The error result:

Plan should allow to add milestones
    Failure/Error: plan.milestones[0].persisted?.should be true
    expected true, got false
    # ./spec/models/plan_spec.rb:19:in `block (2 levels) in <top (required)>'

The line that doesn't work is plan.milestones[0].persisted?.should be true, which means that nested elements do not have persisted? attribute updated... Is this the right way to go, or it should be another way?

Thank you very much

Typo under Standard Persistence, update_attribute

Hi,

There is a small typo under update_attribute.

The example says:

person.update_attribute(first_name, "Jean")

However the "first_name" should be a symbol instead of a variable, so it should be changed to:

person.update_attribute(:first_name, "Jean")

Thanks.

cannot find database!!!

jinleileiking@jinleileiking-virtual-machine:~/work/Chatroom$ rake db:create --trace
(in /home/jinleileiking/work/Chatroom)
** Invoke db:create (first_time)
** Invoke environment (first_time)
** Execute environment
"admin"
String
"admin"
String
nil
NilClass
rake aborted!
db_name must be a string or symbol
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/mongo-1.2.3/lib/mongo/util/support.rb:52:in validate_db_name' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/mongo-1.2.3/lib/mongo/db.rb:80:ininitialize'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/mongo-1.2.3/lib/mongo/connection.rb:282:in new' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/mongo-1.2.3/lib/mongo/connection.rb:282:indb'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.0.rc.7/lib/mongoid/config/database.rb:19:in configure' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.0.rc.7/lib/mongoid/config.rb:322:inconfigure_databases'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.0.rc.7/lib/mongoid/config.rb:110:in from_hash' (eval):2:infrom_hash'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.0.rc.7/lib/mongoid/railtie.rb:66:in block in <class:Railtie>' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:25:ininstance_exec'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:25:in run' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:50:inblock in run_initializers'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:49:in each' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:49:inrun_initializers'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/application.rb:134:in initialize!' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/application.rb:77:inmethod_missing'
/home/jinleileiking/work/Chatroom/config/environment.rb:5:in <top (required)>' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:inrequire'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in block in require' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:inblock in load_dependency'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in new_constants_in' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:inload_dependency'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in require' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/application.rb:103:inrequire_environment!'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/application.rb:216:in block in initialize_tasks' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:636:incall'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:636:in block in execute' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:631:ineach'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:631:in execute' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:597:inblock in invoke_with_call_chain'
/home/jinleileiking/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:607:in block in invoke_prerequisites' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:604:ineach'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:604:in invoke_prerequisites' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:596:inblock in invoke_with_call_chain'
/home/jinleileiking/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:583:in invoke' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in block (2 levels) in top_level' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:ineach'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in block in top_level' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2001:inblock in run'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1998:inrun'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/bin/rake:31:in <top (required)>' /home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:inload'
/home/jinleileiking/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `

'

Update Validation Documentation

We need to update the validation documentation with respect to auto-validating relations... Should be specific on:

  • What relations are validated by default
  • What relations only validate what is in memory
  • What relations validate everything.

Mongoid::MultiParameterAttributes

Hi Durran,

Thanks for fixing the Typo on the installation page (my other issue), not to mention Mongoid itself ;) I guess you can tell I'm an avid RTFMer.

Anyway, just reminding you of another thing to be taken care of, Mongoid::MultiParameterAttributes. I haven't seen this mentioned on the site or the mongoid-site master as of yet and would save some Googling for those who are unaware.

relations/referenced/1-n

I just have a quick question/observation that might need to be fixed on the mongoid.org site.

On the page about 1 to many referenced relations, under the Storage heading,

http://mongoid.org/docs/relations/referenced/1-n.html

it says this:

# The parent person document.
{ "_id" : ObjectId("4d3ed089fb60ab534684b7e9") }

# The child post document.
{
  "_id" : ObjectId("4d3ed089fb60ab534684b7e9"),
  "person_id" : ObjectId("4d3ed089fb60ab534684b7f1")
}

I'm still new to Mongoid and MongoDB but I think I have a decent grasp on database relations and foreign keys (I have been known to be wrong from time to time though). Shouldn't the child's "person_id" be the same as the parent's "_id"?

On the site now the parent "_id" and child "_id" are the same. This just doesn't make sense to me.

Anyway, I just thought that if it needs to be adjusted you'd like to know about it.

Lovin' mongoid and mongo!

Querying for subclasses missing from documentation

I don't seem to be able to find the querying subclasses text anywhere on the documentation anymore. Mind you I could just be blind.

I would please appreciate the text that I pulled from Google cache somewhere in the docs, as I still use it as a reference. Thanks


Fields and validations are inherited down the hierachy, but not up. A subclass will contain all of its parent's fields and validations, but not vise-versa.

Querying for Subclasses
Querying for subclasses is handled in the normal manner, and although the documents are all in the same collection, queries will only return documents of the correct type, similar to Single TableInheritance in ActiveRecord.
Canvas
.where(:name => "Paper") # Returns Canvas documents and subclasses
Firefox
.where(:name => "Window 1") # Returns only Firefox documents

Associations
You can add any type of subclass to a has one or has many association, through either normal setting or through the build and create methods on the association:
firefox = Firefox.new
firefox.shapes.build({ :x => 0, :y => 0 }) # Builds a Shape object
firefox.shapes.build({ :x => 0, :y => 0 }, Circle) # Builds a Circle object
firefox.shapes.create({ :x => 0, :y => 0 }, Rectangle) # Creates a Rectangle object

rect = Rectangle.new(:width => 100, :height => 200)
firefox.shapes

Flesh out Relational Docs

From Trevor Burnham (durran/mongoid issue tracker #156)
http://github.com/durran/mongoid/issues#issue/156


Relational association documentation should be expanded

Given how common relational associations are, even in a NoSQL context (unless your app is super-simple, you can't embed everything, right?), it'd be great if someone would flesh out the relevant docs to explain just what has_one_related and has_many_related do at the MongoDB level, and to provide an example of a many-to-many relationship. As an admitted Mongoid newbie, I'd really appreciate it.

Typo on Installation Page

On the Installation page in the Documentation under Configuration raise_not_found_error, it says that it will raise a Mongoid::Error::DocumentNotFound exception. When I added a line to rescue_from that exception and display an appropriate error page, I got an uninitialized constant Mongoid::Error exception.

After some research, I found the proper name is Mongoid::Errors::DocumentNotFound (note the plural Errors) which is not what it says in the documentation.

add section for reading/writing dynamic attributes

Help new users by adding a section/line in the docs that describes the 'right' way to do reading/write of dynamic model attributes.

Right now that would be:

write_attribute(name, value)
read_attribute(name)

also describe that [] and []= are not overloaded and that's different than what people expect from active record.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.