Reputation: 974
http://bpaste.net/show/6888fe224663
Why is @username non-existent or unavailable at
get '/user/:username' do
puts @username
'hello'
end
It's an instance variable so I assumed it'd be accessible at the point of the puts
. However, it's not printing to the console. What's a better/working way?
Upvotes: 0
Views: 40
Reputation: 21548
There are two ways to get your parameters.
get '/user/:username' do |username|
puts username
'hello'
end
or
get '/user/:username' do
puts params["username"]
'hello'
end
Upvotes: 1