Sunday, January 12, 2014

[Rails] ActiveRecord + self.site dynamic url value

Hello Everyone,

I am using rails 4 version and i am using ActiveRecord to GET and POST data to other rails application.

Below is my product model code 

// product.rb
require 'active_resource'  
class Product < ActiveResource::Base
  self.site = "http://localhost:5000/"
  def other_method
    true
  end
end

My problem is how can i change site url which is in the product model dynamically based on users selection. I have Site model, in that i have list of sites. User should select one site when they try to create a product...

Regards
Saravanan P

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/862abdac-5171-4dd0-bcf1-43817f772e80%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate