similar to: Search HABTM relationship in ActiveRecord

Displaying 20 results from an estimated 1000 matches similar to: "Search HABTM relationship in ActiveRecord"

2006 Jun 07
10
habtm "AND" find conditions
I have two tables and a join table for them e.g. books, authors in a many to many relationship (habtm) and a join table books_authors. I can successfully search for a book that has "author.id = 2 OR author.id = 4" but I am unable to search for "author.id = 2 AND author.id = 4" This is because the result of all the joins only has one author.id column so no single row has
2006 Mar 04
10
Help setting up relationships needed
This is a bit of a long question, but to those of you with some experience, it should be fairly simple I think. I have a notes page that should list all notes the user has entered for all books chronologically like this. Book One: This is the note. Book Four: This is the note. Book One: A different note, entered later. Right now my models are: User has_many :books Book has_many
2006 Apr 24
9
Confusion with expressing many to many relationship
Hi folks, I am in the process of converting an existing non-rails application to rails, and am not sure what the best approach would be for specifying the relationship between the two sets of data. I''ll describe the existing table structures first. Table 1: Urls Each url has a unique id and two lists of Phrases, these are currently setup as varchars with "," delimitation -
2006 Jan 15
0
HABTM relationships and retrieving multiple selects in controller
Hello all, I have a product table and an option table that are connected to one another via a join table. These two tables both contain has_and_belong_to_many relationships with each other. I am trying to setup a page where I will create a product and add in its options. I have already populated the options table with data to draw from. so, to start, here is the method from my controller: def
2005 May 25
2
URLS and Human Factors
This post addresses URLs generated by Ruby on Rails from a human factors point of view. Allow me to use Hieraki as an example. Hieraki is a great application. It was one of my first introductions to the power of Ruby on Rails. Scenario: When I navigated to Chapter 1 of a book the URL in my address bar was http://www.library.com/read/chapter/6. This inconsistancy ("Am I on Chapter 1 or
2009 Feb 23
1
ActiveRecord::AssociationTypeMismatch
I have 2 models: mop, has_and_belong_to_many :contacts contact, has_and_belong_to_many :mops when I save my mop Ii have the users coming in a an array: ["9",10"] I am doing this to asscociate each one to a mop: @contacts.each do |contact| @mop.contacts << contact end Contact(#44950470) expected, got String(#20837400) It is giving me the above error. Any ideas?
2012 Jan 19
1
Samba-vscan Problem
Dear All, I have upgrade my samba from 3.0.33 to 3.3.3, that proces are success but I have a problem for samba-vscan. Error : [2012/01/16 10:32:00.074547, 0] smbd/vfs.c:167(vfs_init_custom) error probing vfs module 'vscan-clamav': NT_STATUS_UNSUCCESSFUL [2012/01/16 10:32:00.074559, 0] smbd/vfs.c:309(smbd_vfs_init) smbd_vfs_init: vfs_init_custom failed for vscan-clamav [2012/01/16
2006 Aug 02
2
many-to-one relationship, do I need a second table?
Ok, to keep things short. Im wondering if I need a secondary relationship table to handle my many-to-one relationships. Here is an example of what I''ve written down. For instance say I want to find all of the people in a given location. class Location < AR:Base has_many :people end class Person < AR:Base belongs_to :location end My SQL tables look like: CREATE TABLE
2006 Mar 19
3
Table belongs_to either of two other tables?
Suppose I have a site about books and authors, and users can leave comments on either a book or an author. I''d want to have a table called "comments", which could belong to either an author OR a book. In my structure I wouldn''t be sure whether to include an "author_id" or a "book_id", or both. What would be the best way to handle this
2005 Nov 28
1
has_one / HABTM relationship overlap - please advise
1. I have a few tables: ''users'', ''shops'', ''addresses'', and ''pictures''. 2. Users and Shops will both use the addresses and pictures tables. I have created several mapping tables: addresses_shops pictures_shops addresses_users pictures_users 3. Users CAN have many addresses and pictures (simple HABTM), but... 4.
2010 Sep 18
1
some question
I am making a program and get some trouble here 1. how do I close all opened child window in mdi form? 2. I cannot disable menu_item, perhaps I use .enable false the wrong way? -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
2006 Jun 09
1
Updating Fields In Migration for HABTM Relationship
Earlier I forgot to add updated_at and created_at columns for my HABTM relationship so I created a migration to add them. In the migration I also want to go back and set the value of the created_at and updated_at columns for the previous rows. What is the best way to do that? Initially I thought I was being smart and decided to put an UPDATE SQL query in a find_by_sql statement and
2006 Apr 17
1
HABTM relationship with two join tables
Ok, I have a People table, a Shows table, a Techs table, and a Castmembers table. The people table has contact info about each person, the techs and castmembers tables have information about the persons specific role in that sshow. i want to call @show.techs (or somethign equivelent, I don''t want to start that code yet) and get all the techs associated with the show, and the
2006 Jan 18
1
HABTM - Destroy just the relationship
If I have a HABTM relationship between two models (places, pictures), can I delete the record from the join table without also destroying the objects? IE: 1. @places.pictures << @picture 2. @places.pictures.find( @picture.id ).destroy I''d want line #2 (...or something similar unless I''m way off) to destroy the record in pictures_places only, and not anything from the
2006 Jan 19
0
Help with nested HABTM relationship
Hi, I am trying to perform a query with ActiveRecord that I want to put into a Rails application later. For now I just wrote it within a plain old Ruby script for easier testing. I am working with an existing database so I had to map some foreign keys myself. As you can see from the models below, the database has a structure of Prospectlists <=habtm=> Contacts <=habtm=> Accounts
2008 Dec 16
1
Callback when objects connect as a habtm relationship
If Product and Category models are in a habtm relationship, i.e. class Product < ActiveRecord::Base has_and_belongs_to_many :categories end class Category < ActiveRecord::Base has_and_belongs_to_many :products end I want a piece of code to be executed every time a product is connected to a category. Where do I put this code? Which callback (and on which model) will be triggered? Any
2006 Jun 10
0
Ordering Based on created_at in HABTM relationship
I have the following line in my controller: @tag = Tag.find_by_name @params[:id] Now, how do I order the rows based on the HABTM relationship problems_tags i.e. problems_tags.created_at DESC Thanks :-) John Kopanas http://www.kopanas.com ============================================================ http://www.soen.info - Index of online software engineering knowledge http://www.cusec.net -
2006 Mar 23
0
HABTM relationship
Hi all, I''ve got the following two objects and the habtm relationship isn''t putting records in the DB: class Cse < ActiveRecord::Base has_and_belongs_to_many :conditions end class Condition < ActiveRecord::Base has_and_belongs_to_many :cses end I''m creating a Cse object and filling the collection of Conditions, then calling save on the Cse object.
2005 Jun 03
1
sorting on a habtm relationship
I have two tables ("products" and "categories") that have a has_and_belongs_to_many relationship, and I need to be able to arbitrarily sort products in the scope of a category using something like acts_as_list. Problem is, since each product can belong to multiple categories, it doesn''t work to use acts_as_list and have the "position" field be in the
2006 May 07
4
Getting column value from lookup table in HABTM relationship
I have a HABTM relationship between my agents and listings tables. Each listing can have many agents and each agent can have many listings. In the agents_listings table I have a column called ''is_primary_agent'' which denotes if the agent is responsible for the listing - only one agent can be primary. At the moment I use this in my listing_controller''s view