Displaying 20 results from an estimated 100000 matches similar to: "Using migration to import data?"
2006 Jan 15
2
acts_as_tree & acts_as_list for a single model?
Hi,
If I have a db table
categories
- id
- name
- parent_id
- position
is it alright to have the Category model act_as_tree and for each
level act_as_list?
class Category < ActiveRecord::Base
acts_as_tree :order => :position
acts_as_list :scope => :parent_id
end
Thanks,
Peter
2006 Jul 19
5
weird result for a custom attr reader!
Hi all,
I am having a weird problem reading a value from my model. basicaly, I
have these two models:
class Category < ActiveRecord::Base
acts_as_tree :order => "name"
belongs_to :item_type
has_many :specific_category_names
end
and
class SpecificCategoryName < ActiveRecord::Base
set_table_name "Specific_category_names"
has_many :products
belongs_to
2007 Aug 30
0
Problem with data migration and acts_as_tree
Hi, this is my first post here, my name is Lucas and I''m just starting
with rails.
For one of the first models I made (an accounts plan), I had some
example data in a CSV file, so I created this migration, the idea is
to detect the parent/child relationships according to the account
number, the code works right (if I insert some puts here and there, I
can see it), but when the migration
2007 Jul 05
0
act_as_tree, belongs_to and has_many foreign keys incorrect
Two models:
class Project << ActiveRecord::Base
has_many :files
end
class File << ActiveRecord::Base
has_one :project
acts_as_tree
end
Inside of the project model, when creating a new product, I want to
store the hierarchy of files within it.
If I do,
my_top_level_file = my_project_object.files.create(:file_name =>
''foo'');
2007 Jul 06
1
migration column options not in schema.rb?
Forgive me if this has been discussed. I''m new to rails and not sure
where to check yet. Also... forgive me if this shows up twice. I tried
posting first through the google groups interface and I''m not sure if it
went through.
I have rails 1.2.3 installed.
I have a migration that looks like
create_table :test_runs do |t|
t.column :test_spec_id, :integer
t.column
2009 Feb 19
3
Associated child records not created on creation of a parent.
I am trying to create a record with association. Within the create
method, I would also like to pre-populate dependent (has_many) records
from a template in the database.
The child records are <u>mysteriously rolled back </u> if I insert
them in a loop. If I try to insert a single child record, it works.I
have read the books and tried to google my way out of this but am at a
dead
2006 Jun 08
7
How to make an OSX Finder in rails/AJAX?
I need to make a category browser that would allow nested categories. Is
there any receipe on that?
Currently, I use the :onchange event from one of the form element to
update the first select (out of 4-5 selects), but I dont know how to
elegantly reset all the child selects if I change the value from the
first.
All the categories are fetched from the DB and I would like a
2006 Jul 13
2
Nested Data
I currently have a database with a table called bookstores. Within that
table are columns such as bookstore name, city, state, and zip code.
What I''d like to do is display the City and then every store name for
that city underneath it.
i.e.
City
- Store 1
- Store 15
Another City
- Store 2
- Store 5
etc. I''ve seen act_as_tree but I don''t know if
2006 Mar 03
1
roobie noobie migration question
I''m just at the "reading various rails tutorials" stage.
One thing that has puzzled me a couple of times so far is the fact that
the creation of the database is not part of the "migration".
The steps as I''ve seen them are always:
1) $ rails myapplication
2) $ mysqladmin yadda yadda to create a table
3) $ script/generate migration myWickedTable
4) put rows
2006 Jun 19
3
Using set_primary_key breaks acts_as_tree with non-integer column
I just switched from using the standard "id" column into using my own
primary key and generating my own unique id for each record. But, this
breaks acts_as_tree.
Because my new primary key is not an integer, it breaks the SQL query
as follows:
StatementInvalid in PagesController#create
--------------------------------------------------------------------------------------
2009 Nov 25
1
CMS act_as_tree and modular architecture
I am developing a CMS using act_as_tree for the pages and act_as _list
to order them (as shown on Railscasts). Each page can load a custom
ERB template, for instance I have one to display a standard article
and one to display a group of articles (so acting as a category of
underling articles).
If I want to develop a forum, let''s say that I have a page with id 5,
with name forum, how can
2007 Oct 22
1
self-referential habtm: why are my keys null?
I''m trying to set up a directional self-referential HABTM to represent
an arbitrary semi-hierarchical structure; it works for any data
prepopulated into the db, but when I try to create a new relationship,
I just get NULLs in both key columns (or 0''s if I turn on the no-null
constraint).
Here are the migrations:
class CreateNodes < ActiveRecord::Migration
def self.up
2006 Jul 18
0
act_as_tree with ordered items
Hello
I am using a data structure that resembles a tree with ordered items. I
know I can use :order in act_as_tree to sort the items at each level,
but since the items have no logical order I would have to use a table
column just to store this order. My experience with position indices of
this kind is that it can lead to inconsistencies in the database so I am
reluctant to use such a
2006 Aug 04
3
Migration::alter statements ??
Hi,
Where to put the execute statements in migration scripts?
e.g, I would like to create a table and add a foreign_key reference.
def self.up
?? execute "alter table ...."
create_table :my_table do |t|
t.column :user, :string
end
?? execute "alter table ...."
end
Should the execute statement be above the table creation or below the table
creation? Logically I
2006 Feb 03
3
how to maintain data while using migration
hi all
started using migration , gr8 stuff
but how can i maintain old data , or import it alongwith schema with same easiness,
as in migration we only import schema ?
thanks
rohit
---------------------------------
Yahoo! Mail - Helps protect you from nasty viruses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2009 May 22
1
[PATCH server] fixed smart pool 'save' regression.
The recent refactoring didn't work properly for new smart pools, so I've cleaned jup the parameter handling for the various pool 'create' actions.
Signed-off-by: Scott Seago <sseago at redhat.com>
---
src/app/controllers/hardware_controller.rb | 5 +----
src/app/controllers/pool_controller.rb | 6 ++++--
src/app/controllers/resources_controller.rb | 6
2005 Dec 23
1
Better way to import initial migration?
On a rails app that I''m developing I converted a regular old .sql file
into a rails migration. Since I generated the migration in my
development environment, it created the schema_info table for me.
However, when I updated my production environment and tried running
rake migrate it complained that schema_info doesn''t exist. Is there a
rake task for getting around this yet, or
2018 May 28
0
Re: VM I/O performance drops dramatically during storage migration with drive-mirror
On Mon, May 28, 2018 at 02:05:05PM +0200, Kashyap Chamarthy wrote:
> Cc the QEMU Block Layer mailing list (qemu-block@nongnu.org),
[Sigh; now add the QEMU BLock Layer e-mail list to Cc, without typos.]
> who might
> have more insights here; and wrap long lines.
>
> On Mon, May 28, 2018 at 06:07:51PM +0800, Chunguang Li wrote:
> > Hi, everyone.
> >
> > Recently
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 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,