Top "Associations" questions

Associations typically refer to relationships between models in ORMs such as ActiveRecord.

Is there any way to check that has_many association exists in Rails 3.1?

For example there are some models class Model_1 < ActiveRecord::Base has_many :images, :as => :imageable end class Model_2 &…

ruby-on-rails activerecord associations
Reassociate files types for visual studio 2012

I've had an install of 2012 for a while, but I've had to also just install VS 2010. As expected, all my …

visual-studio-2010 file associations
Rails 3: validate presence of at least one has many through association item

I have two models: Project and ProjectDiscipline: class Project < ActiveRecord::Base has_many :project_disciplinizations, :dependent => :destroy has_…

ruby-on-rails ruby validation associations has-many-through
Is there a "first_or_build" method on has_many associations?

In rails 3.2+, you can do this : SomeModel.some_scope.first_or_initialize Which means you can also do : OtherModel.some_…

ruby-on-rails activerecord associations
Rails has many and belongs to one

I have a User model which has many projects and a Project model which can have many users, but also …

ruby-on-rails associations has-many has-many-through belongs-to
rails mongoid criteria find by association

I'm trying to find a record by associated username which is included in a belongs_to relation, but it's not …

ruby-on-rails ruby-on-rails-3 mongodb associations mongoid
find_or_initialize_by on has_many association causes duplicate error

I'm seeing a strange error since I moved from Rails 3.0.11 to 3.1.3. Here's a standalone code to reproduce the error: require …

ruby-on-rails activerecord ruby-on-rails-3.1 associations autosave
Rails belongs_to_many

I'm a beginner in Rails and I have a problem with ActiveRecords associations. I'm creating simple car rental service and …

ruby-on-rails activerecord associations
Associating existing unassociated changesets with workitem in TFS

I know there're powerful TFS command line tools from TFS Power tools that provide much more that can be achieved …

associations changeset tfs-workitem
Rails - Testing fixtures error NoMethodError: undefined method `type' for nil:NilClass

I have a problem running tests that use fixtures with associations between models. Here's the error I get, as soon …

ruby-on-rails ruby tdd associations fixtures