On Jun 14, 2007, at 8:35 AM, Rob B. wrote:
may somebody could help me here?
“Doe”)
I think you should seriously consider what liquidautumn says about
-Rob
Rob B. http://agileconsultingllc.com
[email protected]
On Jun 14, 2007, at 8:18 AM, Rafael wrote:
Thats what I have already, but what I don’t want.
On every import cycle, the show id changes for the same vacancy.
so that knowbody can send a link to anybody, because after the import,
the id wont fit any more.
somebody else has a clue?
On Jun 14, 2007, at 8:53 AM, Benjamin C. wrote:
http://agilewebdevelopment.com/rails-ecommerce – build e-commerce
sites with Rails
Ah, perhaps you need something like:
vacancy =
Vacancy.find_or_initialize_by_id_and_first_name_and_last_name(10200,
“John”, “Doe”)
if vacancy.new_record?
vacancy.id = 10200
vacancy.save
end
But you might get better performance using Benjamin’s suggestion if
you just need the “insert only if it’s not there” behavior.
However, if this CSV file can change the name on a specific vacancy:
if vacancy = Vacancy.find_by_id(10200)
vacancy.update_attributes(:first_name => “John”, :last_name => “Doe”)
else
vacancy = Vacancy.new(:first_name => “John”, :last_name => “Doe”)
do |v|
v.id = 10200
v.save
end
end
-Rob
Rob B. http://agileconsultingllc.com
[email protected]