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

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

javascript - Handling constructor related functions while testing with mocha and sinon -