I’m not an expert, just a newbie
What if you try
class Incident < ActiveRecord::Base
has_and_belongs_to_many :condition
end
Class Condition < ActiveRecord::Base
has_and_belongs_to_many :incident
End
Instead of
class Incident < ActiveRecord::Base
has_and_belongs_to_many :conditions
end
Class Condition < ActiveRecord::Base
has_and_belongs_to_many :incidents
End
-----Mensaje original-----
De: [email protected]
[mailto:[email protected]] En nombre de Vince P.
Enviado el: domingo, 29 de enero de 2006 13:53
Para: [email protected]
Asunto: [Rails] HABTM weirdness
Hi Folks,
I’m experiencing some puzzling behavior with a HABTM association. I
have
two models defined as follows:
class Incident < ActiveRecord::Base
has_and_belongs_to_many :conditions
end
Class Condition < ActiveRecord::Base
has_and_belongs_to_many :incidents
End
When I run the following code (irb) the new Condition is not persisted
to
the DB until I call Incident#save. This is what I expect and is not the
problem.
i = Incident.new
i.conditions << Condition.new(:name => ‘some condition’)
Now, my problem is when I add another condition to the saved incident.
Like
this…
i.conditions << Condition.new(:name => ‘some other condition’)
At this point I would not expect to see the new condition persisted to
the
conditions DB table, but I do.
Why is that? Shouldn’t the new condition be persisted to the DB only
after
I call i.save?
On 1/29/06 11:22 AM, “Reis” [email protected] wrote:
Reis wrote:
Wilson B. wrote:
On 1/29/06, Reis [email protected] wrote:
You can do “require_dependency” instead of “require”, in your
environment.rb file.
This is the solution I was searched… thanks so much to all.
But the require_dependency must be setting in
application_controller.rb,
because in the environment.rb file the require and require_dependency
do
the same thing.
Thanks
–Reis
A last question…
Can I load all the module under a directory (only the first level)
So if i have the dir lib with the module mod1.rb and mod2.rb, i can
load
them with a single command.
Thanks
–Reis
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails