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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -