Displaying 20 results from an estimated 7000 matches similar to: "wants to get all parents with no children, etc"
2006 Mar 25
2
acts_as_tree wierdness with children.count and children.size
i am making a category tree and i iterate over the category using my
counter_cache however it would show a different number than what was
actually being represetned in the tree.
Here is an example
cat.children = [cat2, cat3]
puts cat.children.size                            2
puts cat.children_count                         2
cat4.parent_id = cat.id
cat4.save
puts cat.children.size            
2006 Mar 24
6
Should counter_cache fields be saved in the database?
As far as I can tell, the counter_cache option on a belongs_to model
doesn''t actually save anything in the database. For example, I have
the following models:
class Parent < ActiveRecord::Base
  has_many :children,
           :conditions => "deleted_at IS NULL"
end
class Child < ActiveRecord::Base
  belongs_to :parent, :counter_cache => true
end
With the following
2007 Feb 14
3
eager loading parents and children (acts_as_tree)
I am struggling with how to do eager loading of an acts_as_tree model.
If the model Stuff acts_as_tree I know I can do this to get children as
well:
Stuff.find(:all, :include => :children)
But what if the model I am including is the one that acts_as_tree?
For example, say Picture belongs_to Category. Category acts_as_tree and
I want to get all pictures that are members of a category that
2006 Mar 21
5
Order records based on number of children
Let''s say I have simple schema with two tables. The models are defined
like the folllowing:
class Parent < ActiveRecord::Base
  has_many :children
end
class Child < ActiveRecord::Base
  belongs_to :parent
end
Simple has_many relationship. Is there any way to order the results of
a Parent.find_all  by the number of children the parent has? I can
sort with
        sorted_parents =
2006 Jun 08
2
counter_cache is not looking for children_count with acts_as_tree
Hi there, the acts_as_tree API says that I can set a counter cache and
that it will automatically increment the "children_count" column. I
did that but when I create a new page it asks for a "pages_count"
column instead.
Here is the relevant part of page.rb model:
class Page < ActiveRecord::Base
  acts_as_tree :order => :position, :counter_cache => true
 
2006 Apr 07
2
errors.add_to_base
What are the limitations on using:
errors.add_to_base
to display errors in views?
I have tried for days to add errors from my object.rb and they never get 
displayed.
class Keyword < ActiveRecord::Base
    validates_presence_of(:name, :message => "Name is required.")
    validates_uniqueness_of(:name, :message => "This name is already in 
use. Please try
2006 Feb 23
3
has_many: inserting children when inserting parent
disclaimer: am in the midst of my first ruby/rails project
I have a situation where I want several child records to be created when 
a new parent record is created. The following represents my first stab 
at coding it, am I on the right track?
Here is the model:
parents
----------
id
name
children
----------
id
parent_id
name
class Parent < ActiveRecord::Base
  has_many: children
end
2006 Jan 12
4
How do you create a tree strucutre with ActiveRecord
I want to build an application that has the concept of administrative
domains.  What I mean by this is that administrators have access to
different data, based on what domains they are a member of.  The domain
strucutre is hierarchical.  Here is an example:
- MLB
  - AL
    - East
      - Yankees
      - Red Sox
      ...
    + Central
    + West
  - NL
    + East
    + Central
    + West
Now
2006 Jul 13
1
How to create a child from a parent
Hi i am trying to figure out what is the best way to do this very basic 
thing:
lets say i have two tables: one with parents and one with children. 
there is a one to many relation between them.
I scaffolded the parents tabel and i can open each parent. Now i want to 
add a link to the ''show'' view which will create a new child record.
In the model i defined the has_many and
2008 Jul 11
1
Using custom routes to handle new nested resources
I have a couple of resources, one nested in the other, such that my
resource spec in routes.rb is:
  map.resources :parents, :has_many => :children
This will generate a route for a new child that assumes that the parent
has already been saved, something like:
  /parents/:parent_id/children/new
But what if I want a route that handles the case where the parent
resource is also new, and thus
2005 Jul 25
2
acts_as_tree and traversing parent/child relationships
I am working on an Rails application that uses a pretty complex  
category structure through out the site.  I have defined a table to  
house all the info and a FK to reference parents within the table
CREATE TABLE categories (
   id int(11) NOT NULL auto_increment,
   name varchar(50) NOT NULL,
   parent_id int(11) default NULL,
   constraint fk_category_id foreign key (category_id) references  
2006 Apr 27
4
select item based on previous select list selection?
So I have a select list with a list of items. When a user selects an 
item, another select list should have its default selected item set to a 
specific item (the default associated with the first select list).
This is in a form to create a new task. The first select list is a list 
of parent tasks. When one selects the parent task, the clients select 
list must default to the same client as its
2008 May 31
2
Segfault in imap_bodystructure_write when searching
Whenever I try to search on my dovecot test install, dovecot dies. It 
immediately spawns a new process, which the client tries to connect to, and 
send search commands to, causing that to die, and so forth. This loop means I 
have to kill either the server or the client.
Running Dovecot 1.0.13 from/on Debian testing, rebuilt with vpopmail support 
and no other source changes. Vpopmail version is
2006 May 19
1
problem with pdf() R 2.2.1, os 10.4.6
Hi,
I'm trying to write a histogram to a pdf
pdf()
plot<-hist(c, xlim=c( 0.69, 0.84), ylim=c(0,100))
when I try to open the pdf I can't open it, there is always some 
error . Is there something I should add to make it run under this 
operation system? I had problems upgrading to 2.3 (problem 
downloading packages) so I'm not sure an upgrade will work out with 
me. I just want a
2006 Jun 03
2
Parent listing children.
My database is set up as Categories > Things associated by category_id
and has_many and belongs_to.
How would I go about listing all the categories and under each Category
is it''s children? Is there an easy rails way to do this - preferably 
without using acts as tree? Any help is appreciated - thanks!
-- 
Posted via http://www.ruby-forum.com/.
2007 Jan 28
2
help with RandomForest classwt option
Hello there,
I am working on an extremely unbalanced two class classification problems. I
wanna use "classwt" with "down sampling" together. By checking the rfNews()
in R, it looks that classwt is not working yet. Then I looked at the
software from Salford. I did not find the down sampling option.  I am
wondering if you have any experience to deal with this problem. Do you
2005 Feb 22
1
Memory error in Mac OS X Aqua GUI v1.01 with cluster package functions
I'm sorry if the answer to my problem is buried in the archives. I 
have limited experience with R  and I couldn't find a solution to my 
particular problem. I am running  Mac OS X Aqua GUI v1.01 on a new G5 
running os 10.3.8 with a 1.8Ghz processor and 1GB of sdram. I just 
downloaded bioconducter a week ago and I'm trying to cluster a matrix 
I created with a simulation with
2009 Nov 02
3
problems with read.csv
Dear all,
 
I''d like to ask help on R code to get the same results as the following
Splus code:
 
 
>indata<-importData("/home/data_new.csv")
 
>indata[1:5,4]
[1] 0930 1601 1006 1032 1020
 
I tried the following R code:
 
> indata<-read.csv("/home/data_new.csv")
> indata[1:5,4]
[1]  930 1601 1006 1032 1020
 
I''d like the first
2009 Oct 23
2
extract day or month as in Splus
Dear all,
 
I am writing to ask for help to find R code to do the same thing as the
following Splus code:
 
dates <- c("02/27/1992", "02/27/1992", "01/14/1992", "02/28/1992",
"02/01/1992")
timeDate(as.character(dates),in.format="%m/%d/%Y","%a")
[1] Thu Thu Tue Fri Sat
 
Could anyone give me some R codes to get the
2017 Sep 19
3
what do you think about write.table(... qmethod = "excel")?
Last week one of our clients reported trouble with a csv file I
generated with write.table.  He said that columns with quotes for
character variables were rejected by their data importer, which was
revised to match the way Microsoft Excel uses quotation marks in
character variables.  I explained to them that quoted character
variables are virtuous and wise, of course, but they say Microsoft
Excel