Thanks for the quick reply.

>But having two tables with identical structure is smelly.  Why not just 
> use a flag and a named_scope?
I'm not sure what you mean by this.

Yes, both tables have the identical structure but my idea is too delete 
all data from the "import" table after the insert into the "projects" 
table.  This way the user has a fresh table to get info from a csv file.

John

Marnen Laibow-Koser wrote:
> John Mcleod wrote:
>> Hello all,
>> I've been getter better with Rails but I'm still just learning.
>> 
>> Here's what I have.
>> I have one table (imports) and I read in a csv into this table.
>> After doing some preliminary editing to each record I wish to insert all
>> records into another table (projects) in one shot.
>> I could create a new method in the projects controller and then call the
>> "create", but doesn't that only insert one record?
> 
> Yes.  In this case, if the tables have the same structure, you might 
> want to use SQL's INSERT SELECT syntax (see your DB for details).
> 
> But having two tables with identical structure is smelly.  Why not just 
> use a flag and a named_scope?
> 
>> 
>> I need a little clarity on this.
>> 
>> I know how to delete all records from a table. I wonder if it's as
>> simple?
> 
> Rails doesn't abstract this AFAIK, in part because this is very rarely 
> needed.
>> 
>> Thank you for any help.
>> 
>> JohnM
> 
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> mar...@marnen.org

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to