I have two methods auth
and notes
and I want to share a variable between them.
require 'rest_client'
class MynotesController < ApplicationController
obj.instance_eval('@parsedToken')
def auth
username = params[:name]
password = params[:password]
if (username != 0)
token = RestClient.post 'candidate.apiary.io/login', :params => {:username => username, :password => password}
@parsedToken = ActiveSupport::JSON.decode(token)
end
end
def notes
end
end
What should I do if i want to access @parsedToken
in the notes
method?
def notes
"My parsed token is #{@parsed_token}"
end
I would probably use the Ruby style convention to use an underscore to represent space between names, rather than camelCase for names.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments