rein.henrichs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-30 17:32 UTC
Re: def method help
As Raffael suggested, you would need to use an instance variable (@temp) rather than a local variable. The local variable would only be available from the context within which it is called, while the instance variable would be available instance-wide. This sort of situation is where a basic understanding of Ruby comes in handy. A question that I won''t go into, but one that you might want to ask yourself, is whether or not these methods actually belong in your controller. Typically controller methods are either actions or private methods used in filters. Your methods might be better put in either the helper (if they relate to presentation) or the model (if they relate to business or database logic). On Aug 28, 5:57 am, Naveen Palani <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have problems in getting the value from one def method to another. > > For example > > For Example: > > class UserController < ApplicationController > > def dialout(id) [b] # "id" - is taken from database table field [/b] > temp = id > end > > def speak > [b]How can i get the value of temp here[/b] > end > > end > > I created an object for dialout as shown below from which i get the > value id above. > > obj = UserController.new > obj.dialout(user.id) > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---