This is not a question about a specific framework. I am using plain php with jquery. I am trying relate multiple products to multiple sets of options. That is each product can have multiple non-exclusive sets of options related to them. What would be the best way to represent this on screen? I suppose it could be a multiselect box. That ...
I am new to cakephp and I'm trying to accomplish something that should be relatively easy.
I have 2 models projects & categories bind by HABTM relationship.
I am trying to perform the following query -> find all projects that belong to a category
$projects = $this->Project->find('all', array('conditions' => array('Category.slug' => $ca...
There are 2 Models: Project & Category that are bind with HABTM relationship.
I would like to perform a search from projects controller that can do the following:
FIND all DISTINCT Project.scedule WHERE Category.slug != 'uncategorised'
Apologies for the syntax, I'm no sequel expert.
What I have managed to do is to retrieve all projec...
Quoting from the cakephp Book (ver 1.3):
Note that only fields of the model you are directly doing find on will be translated. Models attached via associations won't be translated because triggering callbacks on associated models is currently not supported.
Has anyone come up with a solution for this???
If not could you give...
I have a model Publication and a model Category in my Rails app. Both are connected with a has_and_belongs_to_many association.
Now I would like to search publications that match one or more categories. If more than one category is given they have all assigned to the publication. I want to specify the categories in a multiple select_bo...
I'm doing maintenance work on an existing rails site and have run into a strange bug. There are a few different models involved here: Registrations, Business Categories, and Services. Registrations HABTM Business Categories and Services, each of which HABTM Registrations. The appropriate non-primary-keyed join tables exist for each of ...
I have two models:
The model NetworkObject try to describe "hosts". I want to have a rule with source and destination, so i'm trying to use both objects from the same class since it dont makes sense to create two different classes.
class NetworkObject < ActiveRecord::Base
attr_accessible :ip, :netmask, :name
has_many :statements
...
Hello,
I've got model that use ExtendAssociations, but for some reason deleteHABTM doesn't seem to work on some models (no idea :/). Is there an easy way to just delete a single row from the join table?
Regards,
Paul
...
So I have the Ninja model which has many Hovercrafts through ninja_hovercrafts (which stores the ninja_id and the hovercraft_id).
It is of my understanding that this kind of arrangement should be set in a way that the associative table stores only enough information to bind two different classes.
But I'd like to use the associative tab...
Hi all,
I'd like to know what the best general approach would be for the following:
I have a Showcase and a Showcase has many Image as well as Video.
I would like to have those Images and Videos in one gallery, and I would like to be able to order them within that same gallery.
Images and Videos (can) belong to many galleries.
I'm looki...
I have the following associations:
class User < ActiveRecord::Base
has_and_belongs_to_many :brands, :join_table => 'brands_users'
has_and_belongs_to_many :companies, :join_table => 'companies_users'
end
class Brand < ActiveRecord::Base
belongs_to :company
has_and_belongs_to_many :users, :join_table => 'brands_u...
Suppose I have three models: Student, SchoolClass, and DayOfWeek. There is a HABTM relationship between Student and SchoolClass, and between SchoolClass and DayOfWeek. What I'd like to do is find all school classes belonging to a given student that meet on Monday.
Now I suppose I could do something like:
@student = Student.find(:studen...
Hello all,
I'm sure that this question has been asked somewhere before, as the habtm relationship seems to be very confusing.
I have two models, users and promotions. The idea is that a promotion can have many users, and a user can have many promotions.
class User < ActiveRecord::Base
has_and_belongs_to_many :promotions
end
class ...
Already developed few websites on top of CakePHP but now ran into a brick wall. To make things simple, here's the scenario:
Database Schema:
USERS
- id
- name
RECORDS
- id
- user_id
- timestamp
RECORD_FIELDS
- id
- name
RECORD_DATA
- id
- record_id
- record_field_id
- value
Basically it's an control panel for staff that...
Here's an interesting one for you folks...
I have a HABTM (has_and_belongs_to_many) relationship between "Dogs" and "Trips". My goal is to find two result sets:
1) Dogs that have been on at least 1 of the last 3 trips and call that @dogs_current
2) Dogs that have NOT been on any of the last 3 trips and call that @dogs_old
I found that...
I am trying to model a publications. A publication can have multiple authors and editors. Since it is possible that one person is an author of one publication and an editor of another, no separate models for Authors and Editors:
class Publication < ActiveRecord::Base
has_and_belongs_to_many :authors, :class_name=>'Person'
has_and_be...
Hello everyone.
I have two models set up that I need to save inside one form. When the user uses the "/deliveries/add/" form, I need it to save a new delivery, and also save a new license that is attached to that delivery. This is a hasOne relationship.
Delivery belongsTo License
License hasOne Delivery
Also in the same form, I need...
I have a HABTM relationship between Users and Locations. Both Models have the appropriate $hasAndBelongsToMany variable set.
When I managing User Locations, I want to delete the association between the User and Location, but not the Location. Clearly this Location could belong to other users. I would expect the following code to delete ...
I have the following setup:
class Publication < ActiveRecord::Base
has_and_belongs_to_many :authors, :class_name=>'Person', :join_table => 'authors_publications'
has_and_belongs_to_many :editors, :class_name=>'Person', :join_table => 'editors_publications'
end
class Person < ActiveRecord::Base
has_and_belongs_to_many :publicat...
Hi All,
I have two tables, photos and tags, with a standard photos_tags link table.
My models show Photos HABTM Tags, and I can update both fine with the links updating too.
My question is: say I now want to find all Photos tagged with both "Sunset" and "Ocean" - how do I go about that?
I've tried doing an inner join as per Nate's Ba...