ruby - Grabbing returned variables? -


lets have model called lead , controller method called functions. lead model has method called grab.

def functions     lead.grab(data)     puts newdata end  def grab(data)     newdata = data + 20     return newdata end 

why not work? newdata variable passed functions method cannot seem use without undefined error.

you should have newdata = lead.grab(data). variable newdata in grab function out of scope of controller, can't use it. have set variable in controller returned value of lead.grab(data).


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -