Displaying 20 results from an estimated 10000 matches similar to: "dependent support for has_many through?"
2006 Jul 17
5
quantic phenomena in migrations
I have an application with 15 migrations under version control. In a
Mac and and in a Windows, a rake migrate from scratch runs them all
just fine. But in a different Windows machine rake migrate stops
after migration 3 for no apparent reason. --trace seems normal. No
error is reported. Both Windows are XP SP2. They all have the same
svn revision and Rails-related software, database is
2007 Jun 07
4
checking associated objects have been deleted
I have the following model:
class Book < ActiveRecord::Base
has_many :taggings, :dependent => :delete_all
has_many :tags, :through => :taggings
end
is it possible to check that associated taggings are being destroyed
using mocks? I don''t want to test that rails is deleting the
associations, I want to test that I have specified the association as
a dependent one.
the only
2008 May 28
2
functional testing joins table problem
I have models/controllers
Class Facility
has_many :facilities_services, :dependent => :delete_all
Class Service
has_many :facilities_services, :dependent => :delete_all
Class FacilitiesServices
belongs_to :facility
belongs_to :service
so in my test/functional/facilities_controller_test.rb, I have
post :destroy, :id => 5
which tosses an error...
2006 Apr 26
10
save new model with child model
Hi,
I am having a problem saving a new model that has an associated child
model. If a new ticket is being created and will have one comment to
go with it then I tried this in my action
@ticket = Ticket.new(params[:ticket])
@comment = Comment.new(params[:comment])
@ticket.comments << @comment
if @ticket.save
@notice = "Ticket added. Thanks for
2006 Apr 11
7
Undefined Method
Where can I define the method ''tbluser'' in this error?
NoMethodError in Tblregisteredphone#list
Showing app/views/tblregisteredphone/list.rhtml where line #23 raised:
undefined method `tbluser'' for #<Tblregisteredphone:0x375c778>
Extracted source (around line #23):
20: </font>
21: </td>
22: <td>
23: <%= link_to
2006 May 06
3
Question about one-to-many-to-many
Guys,
I''ve set up a 1-M-M relationship between 3 tables/models. I can''t get
cascading deletes (haven''t tried updates yet) to work when the master
record is deleted. I''m using MySQL 4.1.x, and the error message is:
Mysql::Error: #23000Cannot delete or update a parent row: a foreign key
constraint fails: DELETE FROM contact_addresses WHERE (contact_id = 1).
2006 Feb 07
3
help with relationship
Let''s imagine we are modelling a company that have several shops. I
have a Worker model and a Shop model. A worker belongs_to a shop, and
each shop has_many workers. But, in a shop there''s a distinguished
worker that is the supervisor
create table shops (
...
worker_id integer -- the supervisor
);
How would you express this relationship?
2007 Jan 25
1
has_and_belongs_to won't delete records
Hi,
I have a has_and_belongs_to relationship between 2 objects, order and
product. I''m getting a foreign key violation when trying to delete
Order. Is there a special way of deleting orders without deleting
products? ("has_many" has :dependant => :delete_all.... does
"has_and_belongs_to" have something similar)
Trying:
Order.delete_all
Getting:
Mysql::Error:
2010 Feb 08
5
Why are double sided polymorphic relationships lacking in Rails?
http://stackoverflow.com/questions/2224994/why-are-double-sided-polymorphic-relationships-lacking-in-rails
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
2007 May 17
8
Model: self is not child's parent
Assume a model Parent and another model Child. Child belongs_to Parent
and Parent has_many Children. The following fails:
@
p = Parent.find(:first)
assert p.equal?(p.children[0].parent)
@
It seems odd to me that I and my child''s parent are not the same object.
In fact, this is royally screwing me up. Can anyone tell me why this is
or point me at a relevant discussion, blog posting,
2006 Mar 05
2
depth needed in model()
If there are models of type M in session, and objects of type M
contain objects of type M'', does M'' need to be included in model()?
-- fxn
2006 Sep 03
1
New Technique: Subsets of has_many Associations
I just now thought of this, and sure enough it works like a charm (at
least so far in my limited testing):
has_many :events, :dependent => :delete_all
has_many :upcoming_events, :class_name => "Event", :conditions =>
"date > NOW()"
The purpose of this is that it makes eager loading of subsets of
associations possible without replacing all the magic of the
2008 Feb 15
3
Destroy, dependent and performance
Hi!
This is my first post in this forum. I''m learning RoR for two weeks and
I''m very interested about how to improve this framework.
I was testing one app I''m working in and I had some problems with
destroying.
The code is simple (and maybe wrong, as I said i''m just learning!). When
you destroy a league, you send a message to all the users associated to
this
2010 Aug 17
6
Overly aggressive constant unloading of Rails 3.0
In Rails 3.0 (both RC and edge), any constant that''s defined while loading a
file in development mode will get unloaded on each request, regardless of
whether it comes from an autoload path in the application or from external
code such as a gem.
Example file (tested on a fresh edge app):
# kittens.rb
require ''nibbler/json'' # "nibbler" is a gem specified
2006 Jul 10
18
Deleting join association of has_many :through
I''m trying to use has_many :through, since my join model deserves being
more than just an intersection table.
But when I try to break the association, the break only seems
"temporary":
Let''s say my two tables are Users and Colors, and the join model is
Favorites.
user = Users.find(1)
user.colors.length
>> 2
c = user.colors.first
>> #<Color:....>
2006 Jun 22
1
Active Record question, orphaned children
I have a Deck object and a Card object with their corresponding tables. (You
know a deck of cards.) When I destory a Deck it leaves orphaned cards in
the database. Is there a way to set up the objects with ActiveRecord so that
when a parent object is destoryed the child objects are destroyed as well?
My code below.
class Deck < ActiveRecord::Base
has_many :cards
end
class Card <
2006 Mar 18
1
has_many and validates_associated
By trial and error I seem to arrive to the conclusion that
1. Validation recurses through has_many by default and
a root save! call raises an excepcion if some child no
matter how nested is fails validation
2. Validation does not recurse through has_one by default
and you can change this with validates_associated, in
which case exceptions behave like above
2006 May 30
2
acts_as_queue
wondering if anyone tried this patch. (i havent, seeing as its 1228
lines long, 10 months old, and cant take serious a patch many orders
larger than competing web frameworks)
in many cases i want to keep about 10 things around, eg recent searches,
new items (spanning multiple classes), referers, page views, without
logging them for perpetuity. so i guess this isnt a normal queue, more
like a
2008 Oct 11
8
Observing few fields in a form - Best Practise?
Hi,
im looking to build a page similar to a shopping cart page. When you
change the ''price'' or ''quantity'' fields, the total is calculated and
displayed.
There are other fields in the form which have no relation to this
action. So i guess observe_form is not required. Can someone tell me
what the best practise is for this?
2009 Feb 02
9
ActiveRecord Unexplainable SystemStackError - Only in WEBrick
This SystemStackError is driving me crazy. It only takes place when
testing with WEBrick - I can''t reproduce it with any tests. It is
caused by calling the "missing" id method (base.rb:2435) on my
ActiveRecord class.
WEBrick and my tests are running as the same user, with a `ulimit -s`
of 10240. Plus the query works sometimes so I don''t think this
matters.