I have a main Controlller:
class MainController < Sinatra::Base
set :views, File.expand_path('../../templates', __FILE__)
enable :sessions
helpers AppHelper::Main
end
and a I have a couple of other controllers which inherit from MainController and has its own routes configured with map on config.ru
AuthController
class AuthController < MainController
# Code above
get_login = lambda do
redirect '/' if session[:admin]
erb :login, :layout => false
end
get '/login', &get_login
# Cobe below
end
config.ru
# code above
map('/') { run AppController } # Another inherited controller...
map('/auth') {run AuthController }
on AppHelper::Main I have the following function which I used on a template routed from AppController
def authenticated?
session[:admin]
end
on AuthController I can change session[:admin], but when I try to access session[:admin] on a template which uses authenticated? function it just return nil, as it was not changed. My question is: sinatra session share values through Apps?