has-many
In Rails 2, how would I define a callback method when adding models in a has_many relationship?
In my project I have a Forum that has many Topics, and each Topic has many Posts. When I add a Post to a Topic, I would like to update a timestamp column in the Topic model to record when the last Pos[详细]
2023-01-17 04:28 分类:问答Rails Associations (belongs_to, has_many) can't save 2 ids in table with a create method (user, post, comment)
Trying to write a basic \"blog-like\" app in rails 3, I\'m stuck with associations. I need the create method save the post_id as well as the user_id in the comment table (which I need in order to retr[详细]
2023-01-16 06:58 分类:问答How do I use multiple "one-to-many" nested attributes in form_for
given the fact that a user has many credit cards and a credit card has many addresses, I am trying to create a form that creates a user and credit card with address all at once[详细]
2023-01-16 04:46 分类:问答Creating a named_scope for "no children" in a has_many association
I would 开发者_如何学JAVAlike to have a named_scope for blogs with zero posts. The following does not work.[详细]
2023-01-16 00:48 分类:问答Missing method '%' using has_many and find() in Rails
I\'m getting a very odd error when I attempt to access the find method of a has_many relationship. What am I doing开发者_JS百科 wrong syntactically?[详细]
2023-01-15 19:06 分类:问答Ruby on Rails - has one and belongs to many relationship
This question is related to ruby on rails ActiveRecord associations and how to generate those migrations.[详细]
2023-01-09 04:13 分类:问答belongs_to has_one associated record saving
If i have class User < ActiveRecord::Base has_many :books end . class Book < ActiveRecord::Base belongs_to :user[详细]
2023-01-09 02:35 分类:问答Rails: Non id foreign key lookup ActiveRecord
I want ActiveRecord to lookup by a non-id column from a table. Hope this is clear when I give you my code sample.[详细]
2023-01-08 07:57 分类:问答Rails3: how to set default conditions to has_many
I have boxes and balls. Balls are in boxes. Ball can be either red and green. class Box < ActiveRecord::Base[详细]
2023-01-06 23:42 分类:问答Is there a way to break out of the default_scope when using has_many?
I have a tree-like model where in all situations but one, I want to scope the results to only return the roots.[详细]
2023-01-06 18:05 分类:问答