has-and-belongs-to-many Questions
2
Solved
I have setup this HABTM relationship in the past and it has worked before....Now it isn't and I'm at my wits end trying to figure out what's wrong. I've looked through the rails guides all day and ...
Lyautey asked 14/1, 2011 at 0:47
1
Solved
I'm a rails newbie and I created a scope on a HABTM association, but I still think it looks unnatural, not elegant, so I think there must be a better way of doing it. Could anyone advise me if ther...
Hexavalent asked 26/7, 2015 at 15:22
1
Solved
I have the following bit of code that is working fine with Rails 4.1 with protected_attributes gem (I didn't have my code moved to strong_parameters yet)
models/employee.rb
class Employee
has_and...
Sale asked 11/7, 2015 at 2:46
1
Solved
I'm pretty new on rails 4 and I'm not really sure about how should be my join_table.
I've done the migration
rails g migration CreateJoinTableQuestionSubTopic question sub_topic
And I get this ...
Odeliaodelinda asked 9/6, 2015 at 6:42
1
Solved
I have the tables Semesters, Disciplines and a jointTable Semesters_Disciplines. I want to create a action index in DisciplinesController with a semester_id as parameter, which list with paginate j...
Garin asked 20/4, 2015 at 0:14
6
Solved
In my application everything works fine, but in my Active Admin backend I don't get my user roles displayed on screen.
I have two models "User" and "Roles":
class Role < ActiveRecord::Base
ha...
Specialism asked 14/9, 2011 at 16:48
4
Solved
I have a set of resources called Tasks and Posts and there are in a has_and_belongs_to_many (HABTM) relationship with each other.
There is also a join table connecting their values.
create_table ...
Poon asked 18/10, 2011 at 3:29
1
I use Bllim/Datatables package for the datatables on my web application; but I can't retrieve all the related rows.
I use the code below:
$books= $client->books()->where('books.type', 0);
...
Lupien asked 11/12, 2014 at 13:46
1
Solved
Working with an has_and_belongs_to_many_association
class Category
has_and_belongs_to_many :projects
end
I would would like to use a before_filter to set projects before saving categories
befo...
Veach asked 21/10, 2014 at 16:44
3
Solved
I have some trouble finding a solution for this..
Error: Call to a member function schema() on a non-object
File: /Cake/Model/Model.php
Line: 3627
In my Database there are the tables articles,ha...
Akee asked 11/9, 2014 at 22:13
1
Solved
I've got a simple scenario, but I can't seem to find any proposed solutions that apply to Rails 4. I want to simply add a custom validator that checks the amount of stored associations between my H...
Baguio asked 3/7, 2014 at 17:0
3
I have 2 models. Category and Post. They are connected using a has_many_and_belongs_to_many relationship. I checked in the rails console and the relationship works.
I created checkboxes in active...
Black asked 19/6, 2013 at 20:37
1
Solved
in Ruby on Rails 4, let's say a parent has many children. When the parent is deleted, the children must also be deleted. Other than that, the child shall not be deleted unless it is an orphan. How ...
Oslo asked 14/4, 2014 at 15:27
1
Solved
I am developing a feature for creating specials, for a shopping website. One product can have more than one special, and obviously a special can have more than one product..
I am using a has_and_b...
Towhee asked 22/1, 2014 at 9:31
2
Is HABTM supported by Ransack?
Having the models:
Shop HABTM Categories
Category HABTM Shops
Can I use ransack to search a Shop by a single category?
What does the form look like?
Keynesianism asked 23/7, 2012 at 19:33
1
Solved
I have a has and belongs to many relationship setup like so:
has_and_belongs_to_many :players, :class_name => "User" # In app/models/team.rb
has_and_belongs_to_many :teams # In app/models/user....
Saltpeter asked 20/10, 2013 at 6:4
1
Solved
I'm trying to update a User record with the list of associated Addresses, connected through the has and belongs to many association.
The request body I'm sending through javascript is:
{"id":10,...
Bitterling asked 3/10, 2013 at 15:13
1
Solved
I actually need some advice from advanced Ruby/Rails developers on what's the common and proper way to save a has_and_belongs_to_many association?
Here is what I did, but to me it feels really dir...
Imitative asked 19/9, 2013 at 23:41
1
Solved
I have two models User and Category.
class User < ActiveRecord::Base
has_and_belongs_to_many :categories
accepts_nested_attributes_for :categories
end
similarly
class Category < Act...
Macomber asked 2/9, 2013 at 14:1
2
Solved
In my application a user can follow many users and can be followed by many users.
I tried to model this using has_and_belongs_to_many association
class User < ActiveRecord::Base
has_and_belong...
Decurrent asked 24/2, 2013 at 20:1
2
Solved
I have this relationship between categories, products & brands:
class Brand < ActiveRecord::Base
has_many :products
end
class Category < ActiveRecord::Base
has_and_belongs_to_many :pr...
Rosarosabel asked 9/1, 2013 at 18:1
1
Is it possible to create a hasAndBelongsToMany relationship with Ember.js & ember-data?
Edit: Added ActiveRecord model examples to clarify.
class Project < ActiveRecord::Base
has_and_belo...
Pouter asked 20/8, 2012 at 17:44
2
Solved
I have two models:
#Product
class Product < ActiveRecord::Base
has_and_belongs_to_many :categories
attr_accessible :name
...
end
#Category
class Category < ActiveRecord::Base
has_and_b...
Uprise asked 18/12, 2012 at 8:26
1
Solved
I'm wondering if anyone has experience using Ransack with HABTM relationships. My app has photos which have a habtm relationship with terms (terms are like tags). Here's a simplified explanation of...
Spinose asked 16/11, 2012 at 2:44
2
I have a product model that has many sections, and a section can belong to many products.
The section model has subclasses of Feature, Standard and Option.
My models are:
class Product < Acti...
Assimilative asked 16/6, 2009 at 23:28
© 2022 - 2024 — McMap. All rights reserved.