Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #856 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

Errors in ActiveRecord::Associations::Classmethods documentation

Reported by: U235 (adam@the-kramers.net) Assigned to: David
Priority: normal Milestone: 1.0
Component: ActiveRecord Version: 0.10.0
Severity: normal Keywords:
Cc:

Description

Reading through the docs I found some pretty glaring bugs, unless I'm in a super confused state. Things that don't make sense:

Example: A Post class declares belongs_to :author, which will add:

    * Post#author (similar to Author.find(author_id))
    * Post#author=(author) (similar to post.author_id = author.id)
    * Post#author? (similar to post.author == some_author)
    * Post#author.nil?
    * Post#author.build (similar to Author.new("post_id" => id))
    * Post#author.create (similar to b = Author.new("post_id" => id); b.save; b)

The syntax for build and create is wrong, there is no "post_id" because the field is called "author_id" and exists in the posts table, not authors.

Example: A Firm class declares has_many :clients, which will add:

    * Firm#clients (similar to Clients.find_all "firm_id = #{id}")
    * Firm#clients<<
    * Firm#clients.delete
    * Firm#clients.clear
    * Firm#clients.empty? (similar to firm.clients.size == 0)
    * Firm#clients.size (similar to Client.count "firm_id = #{id}")
    * Firm#clients.find (similar to Client.find_on_conditions(id, "firm_id = #{id}"))
    * Firm#clients.find_all (similar to Client.find_all "firm_id = #{id}")
    * Firm#clients.build (similar to Client.new("firm_id" => id))
    * Firm#clients.create (similar to c = Client.new("client_id" => id); c.save; c)

#create is wrong again, there is no client_id field.

Change History

04/13/05 03:33:02 changed by anonymous

  • milestone set to 1.0.

06/21/05 17:11:06 changed by david

  • status changed from new to closed.
  • resolution set to fixed.