> def update_product_name
>   product = Product.find(params[:id])
>   product.name = params[:name]
>   product.save
>   #Say I want to save this to 3 other databases
>   #can I do this with activerecord?
>   #PSUEDO CODE... I know it cant do this
>   product.save(mysql_host2)
>   product.save(mysql_host3)
>   product.save(mysql_host4)
> end
> 
> Any ideas?  Alternative ways to do this?

I would like to know what their connection are already configured to 
your applications? because to connect multiple databases are different 
configuration or you can do manually connection in your AR (if this is a 
false solution, please give me issues and resolution ):

require "activerecord"

def update_product_name


// i am not sure about this script is put in Class AR
// Maybe it is suitable to put out of class AR
ActiveRecord::Base.establish_connection(
  :adapter=>"mysql",
  :database=>"theSame",
  :username=>"theSame_theSame",
  :password=>"1234567890"
  :host=>"theSame-2.com")

   saving_name(params[:id],params[:name])
end

// you can make array to descript your multiple login then loop it.

end


def saving_name(id,name)
   product = Product.find(id)
   product.name = name
   product.save
   ActiveRecord::Base.remove_connection
end


- Ruby Servant -




-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to