ruby-on-rails,ruby,ruby-on-rails-4,activerecord,has-many
I have three ActiveRecords. Order, which has_many OrderItems. Also has a field named status. OrderItem, which belongs_to an Order and a Script Script, which has_many OrderItems I want to set up the has_many in the Script model so that only OrderItems that belong to an Order which has a status...

sorting,ember.js,has-many,computed-properties
I have asked a variant of this question here. But basically I need to create a computed property that operated on a hasMany association. I need to do sorting similar to the javascript sort function; where I can do something like files = ["File 5", "File 1", "File 3", "File...

ruby-on-rails,activerecord,associations,has-many
I want to create a one to many association between a User and Task model. In my user model I'd like to give it the alias of owner and refer to the user's tasks as owned_tasks. class User < ActiveRecord::Base has_many :owned_tasks, class_name: "Task", as: :owner end class Task <...

ruby-on-rails,ruby,count,has-many
I have: class Constituency < ActiveRecord::Base has_many :votes end class Vote <ActiveRecord::Base belongs_to :constituency end Now, what I want to do is to create a table, that will show me Name of constituency, number of voters (which is easy, as it is part of the table Constituency) and number of...

ruby-on-rails,ruby,has-many,globalize3,globalize
I didn't know exactly how to find an understandable title so I'll try my best to explain my problem. I have 2 models: - Country translatable with globalize, with a name and many regions - Region belongs_to country What I would like to do is geting an array of all...

laravel,has-many
I am trying to print each page's category next to the page's name. so I did a model and named it Page. and inside I have this: public function cat() { return $this->belongsTo('App\Cat'); } this is my controller: public function pages() { $view = view('cp.pages.all'); $view->pages = Page::all(); return $view;...

php,cakephp,has-many
Again I want ask you a question about CakePHP : I have 2 model User and Comment with relation 1-n (One User have many Comment). I want use find() to list infomation both user and it's comments with format data return : Array ( [User] => Array ( [id] =>...

ruby-on-rails,ruby-on-rails-4,activerecord,has-many-through,has-many
I a model like this: class Club < ActiveRecord::Base belongs_to :organization has_many :career_clubs has_many :careers, through: :career_clubs end Which appropriately gets careers through the table career_clubs. So far this is only using the club's id field and getting all the records in the career_clubs table with that id. What I...

mysql,cakephp,has-many,belongs-to
I'm new to cakePHP and the whole MVC architecture. I want to build a Reddit-like comment system where one Comment hasMany Comment(s) but also one Comment belongsTo (only) one Comment. It is the usual comment section where one comment can has a reply to that comment and the reply can...

ruby-on-rails,associations,has-many
TL;DR: How do I use the ID of the respective parent object in a has_many SQL clause to find child objects? Long version: I have the following example code: class Person < AR::Base has_many :purchases, -> { "SELECT * from purchases WHERE purchase.seller_id = #{id} OR purchase.buyer_id = #{id}" }...

javascript,extjs,extjs4,has-many,gridpanel
I am trying to populate all the records at once in a model and then assign each collective property to different container. i.e. I have 1 grid and 1 combo on my page and trying both in one call. So I fetch the data successfully but it comes in forms...

ruby-on-rails,json,rest,has-many,belongs-to
I have two API controllers in my Rails app for a RESTful setup: StoresController (has many products) ProductsController (has one store) How can I write the API so that http://localhost:3000/api/v1/stores/37/products returns only the products for that store(in this case store #37)? I think I'm missing a route and controller method...

ruby-on-rails,ruby,activerecord,has-many-through,has-many
I am modeling a game which has many players. Players can also play multiple games. I have users, games and played_game which is acting as the join table. This is my first foray into has_many :through relationships so I'm hopeful that this is a simple question. Or at least a...