Displaying 20 results from an estimated 70000 matches similar to: "has_many :through and outer join problem"
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:....>
2011 Sep 08
4
In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL
Hello!
At first I posted this in rubyonrails-talk, but no one there was able to
tell me if this is a bug or not (I got only suggestion for workaround).
As this looks like 3.1 regression that breaks existing 3.0.10 code I decided
to post this here in addition.
I''ve upgraded to Rails 3.1 (from 3.0.10), ran my test suite and found this
issue:
class Trade < ActiveRecord::Base
2006 Apr 20
3
has_many :through with has_many/has_many join models
It seems that using a join model that joins with two has_many''s will
fail to generate proper SQL
class StudentSemesterRecord < ActiveRecord::Base
belongs_to :semester
has_many :discipline_records, :through => :semester
end
class Semester < ActiveRecord::Base
has_many :student_semester_records
has_many :discipline_records
end
class DisciplineRecord <
2011 Sep 05
8
In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL
Hello!
Just upgraded to Rails 3.1, ran my test and found this issue:
class Trade < ActiveRecord::Base
has_many :transaction_trades
.....
def Trade.do_something
stale_trades = Trade.count(''transaction_trades.id'',
:include => :transaction_trades,
:group => ''trades.id'')
2006 Jun 09
0
has_many :through troubles
Hi list
I have a question related to an has_many :through association.
Basicly I have a form that updates the entire has_many :through
collection AND the parent object.
from the form I have:
params[:parentobject] (all the attributes related to the parent object)
and
params[:childid]
an array of all the destination ID of the has many through association
How can I cleanly (and maybe atomicly
2006 Apr 21
3
polymorphic,has_many through can not work?
Josh Susser tells in his blog that the opposite direction of polymorphic
will get into trouble together with has_many through.
This is the url:
http://blog.hasmanythrough.com/articles/2006/04/03/polymorphic-through
I do that according to Josh Susser''s procedure:
class Tagging < ActiveRecord::Base
belongs_to :tag
belongs_to :taggable, :polymorphic => true
belongs_to
2006 Jul 28
2
has_many :through with :order column on the join model
I have a model like so
class Product < ActiveRecord::Base
has_many :image_links, :order => :position
has_many :product_images,
:order => ''image_links.position'',
:through => :image_links
end
The problem is that :order clause just gets ignored. How do you server
records in a specific order when the order column is on the join model?
2006 Apr 30
1
has_many :through, form for join model attributes
I have the following schema:
class ClientsProject < ActiveRecord::Base
belongs_to :client
belongs_to :project
end
class Client < ActiveRecord::Base
has_many :clients_projects
has_many :projects, :through => :clients_projects
end
class Project < ActiveRecord::Base
has_many :clients_projects
has_many :clients, :through => :clients_projects
end
I have a form to
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
Hi.
I have a couple of best practices questions regarding polymorphic
associations, naming join tables and user permissions.
Currently I have implemented the user authentication model from the
rails recipes book. Basically it goes something like this:
MODEL CLASSES:
class User < ActiveRecord::Base
has_and_belongs_to_many :roles
end
class Role < ActiveRecord::Base
2006 Apr 05
3
CRUD pattern for has_many relationships (forms containing collections)?
Hello folks!
Beare with me for a second, while I explain my problem.
Assuming we have the trivial model of
class Author
has_many :books
end
class Book
end
How do people go about creating the authors/edit and authors/new
views if you want to be able to add and remove arbitrary amount of
Books at Author creation and edit time? What I mean by this is that I
go to
2006 May 21
3
has_many :through with a polymorphic join
Hi,
Four tables: users, user_counties, uk_counties and us_counties.
Each user has many counties, and each county has many users, so I
decided to make user_counties a polymorph, so it can have counties
from different countries (each country requires a completely different
set of tables with a completely different set of properties, that''s
why there''s one table for uk_counties and
2007 Oct 14
0
naming join models for has_many :through
Hi,
I''m having trouble naming my join models. The tables in question are:
- stores (list of company branches / stocking locations)
- items (inventory items)
- items_stores (item xyz is stocked by store_id 7, their re-order
point is 10, their sales price $27.50)
- items_locations (store_id 7 keeps part xyz on shelf B252)
While I believe items_stores would be proper naming for a
2011 Aug 17
1
has_many :through, collection<<(object) and duplicates.
Hi,
I''m facing a strange behavior in Rails with the has_many association and
the generated collection<<(object, ...) method that comes along.
I''ve got an Object model and a Tag model, plus a taggings table to join
the two together.
On Object, I set these associations:
has_many :taggings, :as => :taggable, :dependent => :destroy
has_many :tags,
2011 Aug 12
1
Getting nil value when setting an on Join model via a has_many :through relationship
Hi All,
I''ve been trying to figure out what''s wrong here for a little over a
day and figured i''d reach out to the ROR list.
A pastie explains the code a bit better than directly in email:
http://pastie.org/private/mvu0zr1xm18bsk6nfbyama
Basically i have an Artist, and he has many Songs through a join model
called Releases. An artist can be "featured" on a
2010 Jul 21
0
One problem with RMySQL and a query that returns an empty recordset
My last query related to this referred to a problem with not being able to
store data. A suggestion was made to try to convert the data returned by
fitdist into a data.frame before using rbind. That failed, but provided the
key to solving the problem (which was to create a data.frame using the
variables fitdist produces in the object it returns).
I now have almost everything working as
2006 Apr 11
3
Validations and has_many :through (Join Models)
Hello again:
I''m hoping that somebody, anybody, can help with this question.
How do I make sure that records in a join model are unique?
Using the scenario outlined in Chad Fowler''s "Rails Recipies", number
16, "Many to Many Relationships Where the Relationship Iteself Has
Data".
Here are the tables:
create_table :magazines do |t|
t.column :title,
2010 Feb 14
2
has_many :through eager loading only loading one record
Hello,
I''ve been using Rails for years, including has_many :through and eager
loading, but this one has me stumped.
The problem is that Active Record is only eager-loading the first of
many records. Here are the models (note set_table_name for a legacy
schema):
class Tag < ActiveRecord::Base
set_table_name ''tag''
end
class DishTag < Tag
has_many
2013 May 22
3
rails 4, active record: appending to has_many :through does not create join model anymore?
hi folks.
on rails 4, can somebody confirm that pushing model instances onto a
has_many :through relation does not create the necessary join model anymore?
class Reader < AR::Base
belongs_to :post
belongs_to :person
end
class Post < AR::Base
has_many :readers
has_many :people, through: :readers
end
@post.people << Person.new
so,
2008 Nov 19
0
has_many through select box in form
Gentlemen,
I have searched the group and have not found any post that clarifies
thsi s=issue to me. Please forgive me in advance if I missed
something.
I have 3 models:
Ticket
has_many :citations, :dependent => :nullify
has_many :violations, :through => :citations
Violation
has_many :citations, :dependent => :nullify
has_many :tickets, :through => :citations
Citation
2006 Aug 12
7
Collection assignment to a has_many :through
I''m working on a simple photo gallery in rails, it seems to be a good
project for a newbie.
I have photos and categories, many-to-many association. It worked well
with HABTM. Then I decided that it would be good to be able to change
order of the photos so that thumbnail pages would look less chaotic.
So I created a Layout model which is a join model (or whatever it is
called) that