I’m completely new in Ruby and Sinatra so please forgive the trivial question:
I wanted to compute the view name instead of just passing in a symbol. I wanted the same action to return different views depending on the current state. There’s like 20 different states so putting a good naming convention allows me to express the view name as a string very easily:
get "/page" do
erb "page-#{session[:page]}"
end
When I do that all I get is the string instead of the rendered view. Can anyone explain to me how I could do that in Sinatra?
I’d say you’re probably looking for
String#to_sym. I didn’t test now, but all the examples sayerbreceives a symbol argument, not a string – so try this:or equivalently