Comments on: Persistent Instance Variables in Ruby on Rails http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/ code like water, compile like bamboo! Tue, 25 Jan 2011 15:52:41 +0000 hourly 1 http://wordpress.org/?v=3.2.1 By: Riccardo http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/comment-page-1/#comment-70 Riccardo Wed, 22 Oct 2008 08:15:40 +0000 http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/#comment-70 Hi, i'm trying to use class variable but i'm not able to do that.. can anyone explain me how can i set and retrieve the value of the variable? Thanks! Hi,

i’m trying to use class variable but i’m not able to do that.. can anyone explain me how can i set and retrieve the value of the variable?

Thanks!

]]>
By: Glenn Ford http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/comment-page-1/#comment-67 Glenn Ford Tue, 07 Oct 2008 14:22:43 +0000 http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/#comment-67 @Sam: If it's only one variable, just set it in a class method: <pre> def self.project_name=(new_name) @@project_name = new_name end def self.project_name @@project_name end </pre> This should be accessible from anywhere by calling <code>ClassName.project_name</code> Does that help? @Sam: If it’s only one variable, just set it in a class method:

def self.project_name=(new_name)
   @@project_name = new_name
end
def self.project_name
   @@project_name
end

This should be accessible from anywhere by calling ClassName.project_name

Does that help?

]]>
By: Sam http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/comment-page-1/#comment-66 Sam Tue, 07 Oct 2008 07:07:03 +0000 http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/#comment-66 Hi, I am also facing the same problem in one of my projects, but with only one variable and I am not using a list. How about then.. how can persist the values.. Hi, I am also facing the same problem in one of my projects, but with only one variable and I am not using a list. How about then.. how can persist the values..

]]>
By: Deepak http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/comment-page-1/#comment-54 Deepak Wed, 27 Aug 2008 09:46:50 +0000 http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/#comment-54 How i take data from static variable which i put in model,can we do caching statically How i take data from static variable which i put in model,can we do caching statically

]]>
By: Deepak http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/comment-page-1/#comment-53 Deepak Wed, 27 Aug 2008 09:45:11 +0000 http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/#comment-53 Its good Its good

]]>
By: Glenn Ford http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/comment-page-1/#comment-21 Glenn Ford Wed, 09 Apr 2008 16:12:13 +0000 http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/#comment-21 Gwyn, great question! I tested locally starting up two environments to be sure and found that they do not share instance variables across servers. I'm pretty sure that instance/class variables are stored in memory, meaning they will only be available to the local environment. The catch is that grabbing the same model on each environment will give you two separate instances, and thus two separate sets of instance variables. If you need data to extend to everywhere, including across your separate Mongrel's, you'll need to store it in the db. Gwyn, great question! I tested locally starting up two environments to be sure and found that they do not share instance variables across servers. I’m pretty sure that instance/class variables are stored in memory, meaning they will only be available to the local environment.

The catch is that grabbing the same model on each environment will give you two separate instances, and thus two separate sets of instance variables.

If you need data to extend to everywhere, including across your separate Mongrel’s, you’ll need to store it in the db.

]]>
By: Gwyn Morfey http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/comment-page-1/#comment-20 Gwyn Morfey Wed, 09 Apr 2008 09:57:11 +0000 http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/#comment-20 What do your deployments look like? Does this work if Mongrel#1 handles the first request, and Mongrel#2 handles the second one? What do your deployments look like? Does this work if Mongrel#1 handles the first request, and Mongrel#2 handles the second one?

]]>
By: Glenn Ford http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/comment-page-1/#comment-19 Glenn Ford Sat, 05 Apr 2008 14:51:47 +0000 http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/#comment-19 Certainly! I'll append it to the blog itself so that it's easier to follow. Thank you for the question. Certainly! I’ll append it to the blog itself so that it’s easier to follow. Thank you for the question.

]]>
By: hvm http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/comment-page-1/#comment-18 hvm Sat, 05 Apr 2008 04:03:39 +0000 http://www.glennfu.com/2008/02/20/persistent-instance-variables-in-ruby-on-rails/#comment-18 Thank you, however, How do you use the variable ?, I meant how do you store data into and get data out of those variables? could you give an example of that? Thank you, however, How do you use the variable ?, I meant how do you store data into and get data out of those variables? could you give an example of that?

]]>