Displaying 20 results from an estimated 224 matches for "parent_id".
Did you mean:
parent_pid
2006 Jun 19
3
Using set_primary_key breaks acts_as_tree with non-integer column
...nteger, it breaks the SQL query
as follows:
StatementInvalid in PagesController#create
--------------------------------------------------------------------------------------
Mysql::Error: #42S22Unknown column ''1_3'' in ''where clause'': SELECT *
FROM pages WHERE (parent_id = 1_3 AND account_id = 1) ORDER BY
position DESC LIMIT 1
Because parent_id is also now a :string column, the 1_3 should be put
into single quotes like so:
SELECT * FROM pages WHERE (parent_id = ''1_3'' AND account_id = 1)
ORDER BY position DESC LIMIT 1
... but acts_as_tree...
2005 Nov 25
2
acts_as_list with 2 fields in the scope
Hi Railers,
I''ve got a Categories table.
I want it to act as a list within the scope of the parent_id AND the
site_id.
Categories table :
id
label
site_id
parent_id
So, in my Category class, I have :
acts_as_list :scope => ''site_id = #{site_id} AND parent_id = #
{parent_id}''
The problem is that when I try to move_up a Category with a parent_id
that is null, the generat...
2009 May 22
1
[PATCH server] fixed smart pool 'save' regression.
.....6d879b9 100644
--- a/src/app/controllers/hardware_controller.rb
+++ b/src/app/controllers/hardware_controller.rb
@@ -187,10 +187,7 @@ class HardwareController < PoolController
end
def additional_create_params
- ret_hash = {:resource_ids => params[:resource_ids],
- :parent_id => (params[:hardware_pool] ?
- params[:hardware_pool][:parent_id] :
- params[:parent_id])}
+ ret_hash = {:resource_ids => params[:resource_ids]}
ret_hash[:resource_type] = Host if params[:resource_type] == "hosts"...
2006 May 07
3
Stupid newbie question
Here''s a request string which has a value I want to pull out from the
category array - parent_id.
Parameters: {"category"=>{"name"=>"Condiments", "parent_id"=>"1"},
"commit"=>"Create"}
How do I reference that subelement in the receiving script? I''ve tried
params[:parent_id]
params[:category[:parent_...
2005 Sep 23
6
problem with acts_as_tree
...rails book. So
I have something like:
class Category < ActiveRecord::Base
acts_as_tree :order => "title"
end
create table categories (
id int not null
auto_increment,
title varchar(100) not null,
parent_id int,
constraint fk_category foreign key (parent_id)
references categories(id),
primary key (id)
);
When I try to use category.children I get an invalid member error.
When I changed this to:
class Category < ActiveRecord::Base
belongs_to :parent,...
2014 Nov 24
3
[PATCH] v2v: -i ova: Remove incorrect warning for disks that have no parent controller (RHBZ#1167302).
...f --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 95af2e5..9a9c10a 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -187,14 +187,17 @@ object
for i = 0 to nr_nodes-1 do
let n = Xml.xpathobj_node doc obj i in
Xml.xpathctx_set_current_context xpathctx n;
- let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
(* XXX We assume the OVF lists these in order.
let address = xpath_to_int "rasd:AddressOnParent/text()" 0 in
*)
(* Find the parent controller. *)
- let controller = parent_controller parent_i...
2006 Apr 30
4
acts_as_ordered_tree
I need an ordered (sortable tree) and I just was thinking if somehting
like this is possible:
class Item< ActiveRecord::Base
acts_as_tree :order => "position"
acts_as_list :scope => ''parent_id = #{self.id}''
end
For my understanding mixing of two acts_as should be p?ssible, at least
in this case, right?
Unfortunatly the :scope is not working, I am not sure how to write the
scope so that only items are treated as list whos parent_id is like
mine.
I tried:
''parent_id...
2009 Feb 20
1
better nested set and parent_id
Hello everybody
I have a model with better_nested_set. In my "new" form, i pass the
desired parent_id as a hidden field, and in the create action at the
controller i save the new register and use move_to_child_of Model
(params[item][parent_id])
Everything works, but at my log file it warns that i can''t mass asign
the property "parent_id".
What can i do to avoid the warning?
--...
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 Apr 07
6
validation nightmare
Please help, I am really at a loss at how validation is supposed to work
in rails.
Model contains
acts_as_tree
I want to force my NEW objects to have a parent
I do NOT want existing object to have a parent
so I only want to have parent_id on create, NOT on update.
I am trying this:
def validate_on_create
validates_presence_of :parent_id, :message => "You must specify a
parent for this keyword."
end
and I get:
undefined method `validates_presence_of'' for #<Keyword:0xb774aba0>
The only...
2007 Oct 12
3
Models that reference themselves
...dels and relationships.
In one project I have a hierarchy of (geographical) sites. For
example:
Earth
Europe
Ireland
Cork
Kerry
Galway
......
UK
France
America
If I were using any other language my sites model would look like:
id, # Primary Key
site_name,
parent_id # references the id of this site''s parent.
In Rails I think I need to:
1. Drop the parent_id column
2. Use a bridge table to bridge the site id back to the parent site
record and
3. A has_and_belongs_to_many relationship
Is this the correct approach?
I''m sure this must have be...
2007 Jan 17
2
rake test and validates_inclusion_of
...e always ones that are asserting that a
model, which has a reference to another model, is OK. So for example,
one assertion that passes when I do `ruby
test/unit/department_test.rb`, but fails when I do `rake test` is:
department = Department.new(:name => "super department",
:parent_id => departments(:administration_department).id)
assert department.save
When I print out department.errors, I see that parent_id is invalid
because it "is not included in the list".
The validation I have on parent_id is:
validates_inclusion_of :parent_id, :in => Department.find_all...
2005 Jul 25
2
acts_as_tree and traversing parent/child relationships
...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
categories(id),
PRIMARY KEY (id)
);
My goal was to be able to set the names to reference other entries in
the table, establishing the parent/child relationship
parent = id: 1 name: Category 1 parent_id...
2006 Mar 15
5
acts_as_threaded - help ???
...ast.
When I submit the post I get an SQL error:
PGError: ERROR: null value in column "root_id" violates not-null constraint:
INSERT INTO posts ("name", "updated_at", "body", "depth", "lft",
"subject", "root_id", "parent_id", "rgt", "created_at")
VALUES(''Richard Nixon'', ''2006-03-14 19:45:58'',
''Erase tape number 2347!'', 0, 0, ''Memo'', NULL, NULL, 0,
''2006-03-14 19:43:00'')
We can see NULL values being provi...
2009 Feb 19
3
Associated child records not created on creation of a parent.
...lem Statement ------------
PrototypeModel has many Departments .
Departments may also be grouped within Departments.
Trying to create a new PrototypeModel and populating the departments
(behind the scenes) from a template PrototypeModel specified by the
user in params[:prototype_model][:parent_id].
The save of the PrototypeModel fails as the new Department records are
invalid.
I checked the instances and find that the department.id is
nil. But that id is supposed to be populated by the associated
save! If I replace the departments.build argument in the
controller::create with a s...
2006 Apr 27
4
select item based on previous select list selection?
...come across several part examples using remote_function or rjs, but
my rails newbieness is preventing me from understanding those
completely. Does anyone have complete code or a suggestion as to how to
accomplish this.
This is my existing code:
<%= select (''task'', ''parent_id'', @parents.collect {|p| [ p.title, p.id ]
}, { :include_blank => true }) %>
<%= select (''task'', ''client_id'', @clients.collect {|c| [ c.name, c.id ]
}) %>
Thx
N.
--
Posted via http://www.ruby-forum.com/.
2006 Apr 20
1
Rails is losing key information
...SERT INTO QUESTIONS () VALUES (''15'', ''1'', ''45'', ''7'', ''0'', NULL, ''46'',
''45'');
----------------------------------
Results in database:
----------------------------------
ID PARENT_ID PRESENTATION_ID
14 1 43
SEQ POINTS TIME_ALLOWED
6 0 [null]
TIP_PRESENTATION_ID EXPLANATION_PRESENTATION_ID
44 43
----------------------------------
Firebird DDL:
----------------------------------
create table presentations
(
ID INTEGER not null primary key,
textvalue varchar (1024),...
2006 Jun 16
1
sortable acts_as_tree with heirarchy
...got the drag and
drop working on children, but as can''t get it to save the tree.
Here''s my view:
<h2>Menu Prototype 2</h2>
<%= flash[:notice] %>
<ul id="menu">
<% @navigation.each do |link| %>
<li class="edit_link level<%= link.parent_id %>" id="_<%= link.id.to_s
%>">
<%= link.name %>
<ul class="edit_list">
<% link.children.each do |child| %>
<li class="edit_link level<%= child.parent_id %>" id="_<%=
child.id.to_s %>">
<%=...
2006 Jan 09
1
Saving an upload
..."films_pictures"
attr_writer :uploaded_files
attr_reader :uploaded_files
validates_presence_of :name, :description, :has_subtitles,
:is_censored
end
picture.rb:
class Picture < ActiveRecord::Base
has_many :films
has_many :comics
acts_as_list :picture_id
attr_writer :parent_id
attr_writer :type
validates_presence_of :filename, :content_type
def after_save
p self.inspect
# If a file was uploaded, save it
if @temp_file
# Check the existence of the dir before writing
#item = get_parent
#upload_dir = File.expand_path(UPLOAD_PATH) +
"...
2006 Feb 08
1
Many-To-Many w/acts_as_tree?
...''m having a problem getting acts_as_tree working. It seems from the
Agile book (p. 255) that acts_as_tree only supports one-to-one record
relations, whereas I need many-to-many support. In other words, looking
at the picture at the top of page 256 where where only 1 id is linked to
1 parent_id, I need multiple id''s linked to multiple parent_id''s - for
example, id = 6 linked to not only parent_id 3, but also parent_id 7 and
5 (not really parents, just linked). Obviously w/the id column being a
primary key, duplicate values of id = 6 isn''t going to work.
Any...