Displaying 4 results from an estimated 4 matches for "association_nam".
Did you mean:
association_name
2007 Mar 29
21
a better "should have valid associations"
This is pretty much the same as last time around, if you recall.
Thanks to Wilson for converting to the new form. I''ve added a few
lines. Basically, it iterates over your model associations and does
two things.
- First, just try to call the association. Usually fixes speeling
erors or other such silliness.
- Second, try to find a record with an :include on the association.
This
2005 Dec 31
6
habtm recursion via destroy_without_callbacks
I am having a problem with two models that each have a HABTM
relationship to the other. For example:
CREATE TABLE people (id INT, name TEXT);
CREATE TABLE teams (id INT, name TEXT);
CREATE TABLE people_teams (person_id INT, team_id INT);
The person model has:
has_and_belongs_to_many :teams
And the team model has:
has_and_belongs_to_many :people
The trouble comes when trying to destroy
2007 Oct 05
7
Easy AR association stubbing
...urn(mock_model(Post, :save => true))
@person.stub!(:posts).and_return(posts)
# now
@person = mock_model(Person)
@person.stub_association!(:posts, :find_by_title => mock_model(Post))
Just add this to the spec helper
module Spec
module Mocks
module Methods
def stub_association!(association_name, methods_to_be_stubbed = {})
mock_association = Spec::Mocks::Mock.new(association_name.to_s)
methods_to_be_stubbed.each do |method, return_value|
mock_association.stub!(method).and_return(return_value)
end
self.stub!(association_name).and_return(mock_assoc...
2005 Nov 04
0
habtm's collection_remove deprecated
...about the collection_remove
method added to models with has_and_belongs_to_many associations. This
function is not listed in the documentation, but is still there in
Rails 0.14.
I noticed this in the source for has_and_belongs_to_many:
# deprecated api
. . .
deprecated_remove_association_relation(association_name)
What does it mean for a method to be deprecated? Will future versions
of Rails drop it? In that case, should I replace it with some manual
functionality (collection.delete does only half the job as it deletes
the corresponding row in the join table but doesn''t remove the object
from the...