similar to: as_json and self-referential associations

Displaying 20 results from an estimated 2000 matches similar to: "as_json and self-referential associations"

2012 Sep 28
1
How to Include Associations in #as_json
Hi, Does anyone know how to include nested associations when overriding a model''s #as_json method? Below is my attempt to include direct and nested associations. NOTE: "office" is a direct association, "company" is nested association via "office". I''d like both included in the generated json output. def as_json(options={}) super(:include
2006 Feb 22
2
Newbie seeks helps ordering ancestors from acts_as_tree
I''m sure this is really obvious but I''m feeling my way here with rails (and Ruby) and have tried a couple of things without success. So, can anyone tell me the best way to reverse order the retuen list of ancestors. In the controller I have: @ancestors = @category.ancestors which returns an array starting at the parent and ending with the root. When I then loop through the
2006 Oct 02
0
list of methods derived from associations?
Hello; I''m at this point essentially a Rails hobbiest: entranced, enthralled, immersed but not writing Rails apps commercially. I am sure my question has been asked and answered but I searched and couldn''t find it, so.... Is there somewhere a list of methods that become available via associations? I was doing a project with acts_as_tree and was struggling with a breadcrumb
2007 Apr 30
2
acts_as_tree
Hi folks, For my app, I needed to modify acts_as_tree (ActiveRecord::Acts::Tree) such that deleting a node would orphan sub-nodes, rather than deleting them. This is accomplished simply by allowing a :dependent option to the acts_as_tree method so that it can be set to :nullify. For my app, I simply did this by adding a file tree.rb to my lib directory and requiring it in the model. A number
2006 Nov 29
4
how do I model self-referential entities?
Hi all - I am having some trouble figuring out how to model self-referential entities in Rails. I have a "group" model, which can have 0 or more "group" objects or 0 or more "user" objects. I tried creating a subgroup table that has a parent_group_id and a child_group_id as foreign keys but can''t figure out how to create the mapping in my ruby model
2006 Jan 19
0
Problem with an Tree-like object hierarchy (ActiveRecord acts_as_tree)
Hello people on rails, I am developing a web interface for a database that has hierarchical data. I want the user to be able to browse the tree (~1300 nodes) and activate/deactivate and showing/hiding groups of nodes (like selecting one node selects all the children and the leafs). So I have a tree of objects (ActiveRecord acts_as_tree). Because I need the tree to be persistent and I
2010 Mar 24
4
grouping and acts_as_tree
hi, im using acts_as_tree and im not sure on how to group find-result. x = find.almost_all <p> <% for y in @x.ancestors.reverse %> <%= link_to h(y.title), page %> &gt; <% end %> </p> gives me a nice "breadcrum". but how is it possible to group the list lets say by the 1level or second level? thx -- You received this message because you are
2011 Feb 03
0
Correct way to exclude attributes from json serialization
Hi I''m using Mongoid and Rails 3, and I want to serialize one of my mongoid documents to json for publishing via a controller, e.g. class ReportController < ApplicationController respond_to :json def show report = Report.where(:report_id => params[:id]).first respond_with report end end This works ok, but pushes out every attribute on the document
2008 Sep 26
0
self-referential tags, has_many_polymorphs
Hi, I''m looking to add tagging to an application, and I would like to allow self-referential tags, so that I can tag my tags. With the goal of generating a flexible tag hierarchy. After some googling it looks like acts_as_taggable is not the best piece of code, and I''m hoping to use the has_many_polymorphs plugin from http://github.com/fauna/has_many_polymorphs/tree/master.
2012 Oct 22
0
[LLVMdev] Self-referential instruction from jump threading
Hi Hal, > After investigating PR14133, I've discovered that jump threading can output self-referential instructions: > %inc.us = add nsw i32 %inc.us, 1 such instructions are valid in unreachable basic blocks. > At least in the test case for that bug report, the relevant code is later deleted (perhaps it is unreachable), and so this does not cause a problem. Unfortunately, when
2012 Oct 22
0
[LLVMdev] Self-referential instruction from jump threading
Hal Finkel wrote: > Hello, > > After investigating PR14133, I've discovered that jump threading can output self-referential instructions: > %inc.us = add nsw i32 %inc.us, 1 > > At least in the test case for that bug report, the relevant code is later deleted (perhaps it is unreachable), and so this does not cause a problem. Unfortunately, when vectorization is enabled, this
2007 Jul 26
1
Bi-directional self-referential HABTM
Hi, I''m having a little trouble figuring out how to make a self- referential HABTM bi-directional. I have a Employee class. Each employee can have a couple of bosses, who are also employees. The employee class has the following HABTM: has_and_belongs_to_many :bosses, :class_name => "Employee", :join_table => "bosses_courses", :association_foreign_key =>
2006 Jul 20
1
self referential xml using builder
Hi listers, I''m trying to build an xml doc using Builder, but I''m having trouble getting it to draw a tree structure from a self-referential table. Here''s what I''m after: ========================== ---- object structure ---- node (name => root) - node (name => child 1) - node (name => child 2) - node (name => child 2.1) - node
2006 May 02
0
Self-referential MtoM implementation
ok, guys i have followed the self referential recipe from the book it works perfect but now i have some doubts, at the end the model are modified to force the user beign added as a friend that add too who are adding him so how i can make that the full relationship doesn?t be complete until the friend beign added approves it(talking in the implementation of the code of course)? by the way,
2006 Apr 17
0
Pros/cons of doubling up in Self-Referential has_many via :through
Relative newbie so would welcome comments re structure of a self-referential relationship I''ve got. It''s started off similar to the Person HABTM friends in the Rails recipes books (working fine), but I needed to turn the join table into a full-blown model as I wanted to add attributes to it. Few tricky bits dealing with the new :through structure and understanding how :scope
2008 Jan 23
1
Self-referential HABTM SQL mal-formed when updating record
Guys, Anyone ever had this kind of problem with ActiveScaffold? Cheers, Sazima ------------------------------------------------------------------------------------------------ What steps will reproduce the problem? 1. Create self-referential HABTM application (like the common "user has friends" example) 2. Try to add more than 1 friend to a given user using ActiveScaffold. What is
2006 Feb 25
0
self referential habtm using join tables
All: I have been working on making a self-referential habtm relationship that uses a join model because I want to store info about the relationship. I have been using two sections from Chad Fowler''s "Rails Recipes" as a guide, "Self-referential Many-to-Many Relationships" and "Many to Many Relationships Where the Relationship Itself has Data". So far I have
2012 Jul 06
2
[LLVMdev] Self-referential function pointer
Hey guys, I could use some advice on a special case of a function pointer as a formal argument. I would like the function pointer type to contain the actual signature of the function, i.e. not a pointer to var args function. This becomes an issue when I have a function which can take a pointer to itself as an argument... our terminology for this is "a recursive procedure". That is, of
2006 Feb 27
0
self-referential many-to-many using a join model
Hello! I have been working on making a self-referential habtm relationship that uses a join model because I want to store info about the relationship. I have been using two sections from Chad Fowler''s "Rails Recipes" as a guide, "Self-referential Many-to-Many Relationships" and "Many to Many Relationships Where the Relationship Itself has Data". So far I
2006 Mar 25
0
Self-Referential Many-To-Many relationships where the relationship itself has data.
Trying to model a bunch of users that have friends that are other users. clearly a job for has_and_belongs_to_many, but the trick is, they have ratings for their friends. I have gone through the Rails Recipes book, and it seems like I''m trying to combine the self-referential many-to-many recipe (12) and the many to many relationships where the relationship itself has data recipe (16). So