Flashcard (Front and Back)

Front (Question)

If you want rails to track the number of records a has_many relationship has, what is the syntax

Back (Answer)

in the master table add a field with xxxx_count where xxx is the name of the has_many table and :counter_cache => true to the belongs_to

ex: if the learner

has_many :flashcards

then you add flashcards_count to the learner table and in the flashcard model

belongs_to :learner, :counter_cache=>true



Memory Work Out Sessions use brain research to accelerate and improve memorization. Automatically scheduled daily review drills ensure sure you don't forget.





or Find more than 100,000 other things to learn

Educators and Trainers:

Tour YoYoBrain's resources for learning and teaching
Previous Card See the whole card set Next Card


Comments:

Other flashcards from Practical Rails Social Networking Sites
Rails: How do you define a REST reso...       When you create a REST resource by ma...       Rails: How do you automatically gene...       How can you add way to show user by n...       What is the purpose of the :collectio...       When using a nested resource in a url...       when using validates_length_of, how a...       Rails: What statement do you put in ...       Rails: When adding a table in a migr...       Rails: How do you tell model to null...       If you want rails to track the number...       Rails 2.0 new preferred way of establ...       Rails: How do you convert a time to ...       Rails: How can you see the existing ...       How can you add your own format to Ti...       What is the Textile language       What is a RedCloth gem       Rails plugin that allow adding captch...       What is the name for Rails support fo...       Rails: How do you generate the code ...       Rails plugin to handle large email tr...       Rails: What is the plugin Liquid use...       How do you set up a response to rss a...       2 ways for user request to indicate i...       How can you get controller to render ...       How can you get controller to render ...       Rails: How do you create a view file...       Rails: What tag must be present in h...       Rails: How can you put custom conten...       Rails plugin to allow handling of fil...       How do you tell model that it will be...       Property of attachment_fu model that ...       Rails: What is the newer tagging plu...       What 2 tables are use by acts_as_tagg...       How do you mark a model as having tag...       Rails: What property is used to read...       What method is used to find objects w...       How do you find an object that has al...      





App_store_badge
What's new | About Us | Privacy Policy | Copyright Policy | Contact Us

Copyright 2007-2025 YoYoBrain.com

Managed By W3mg