Ruby Sinatra NoMethodError
I've tried running this with Ruby 1.9.3 as well as 2.0, but nothing seemed
to work. Here's the code:
require 'sinatra'
before do
set :display_string, 'Welcome from Ruby!'
end
get '/' do
settings.display_string
end
The error is:
NoMethodError at /
undefined method `set' for (sinatra application code here)
This code:
set :display_string, 'Welcome from Ruby!'
seems to cause the issue. I'm running Thin 1.5.1 , latest version of
Sinatra 1.4.3
EDIT: It seems that this works well if set is not inside the "before
do/end" block. So it's something about the set being in the before do/end
block.
No comments:
Post a Comment