An Issue with Passenger and Sessions

30 views
Skip to first unread message

Luke Matthew Sutton

unread,
Jul 7, 2008, 3:49:02 AM7/7/08
to sinatrarb
Hello,

I've been having a lovely time working with Sinatra lately and I'm
happy to say i've only encountered one major kink so far…
unfortunately I haven't managed to solve it.

I've deployed a sinatra app under Apache using Passenger, it works
perfectly aside from the sessions. I've made sure the sessions are on
in all environments.

Sinatra::Application.default_options.merge!(:sessions => true)

The sessions work fine in development mode, but when I try to use them
in production under Passenger, no values get stored.

Does anyone have any experience with this?

Thanks!

--
Luke

Craig Jolicoeur

unread,
Jul 7, 2008, 9:34:41 AM7/7/08
to sina...@googlegroups.com
Are you using the default cookie session store or some other kind?

Luke Matthew Sutton

unread,
Jul 7, 2008, 7:28:45 PM7/7/08
to sinatrarb
The default cookie store, or at least I haven't changed anything from
the default.

I did wonder if this had something to do with the apache or passenger
configuration i.e. it's not tracking sessions for this particular
virtual host.

That seems a bit strange, since I have a merb app deployed with the
same settings and it behaves correctly.

I'll keep poking about.

Blake Mizerany

unread,
Jul 7, 2008, 9:26:24 PM7/7/08
to sina...@googlegroups.com
enable :sessions

should be the only thing you need to get started.
--
Blake Mizerany
blake.m...@gmail.com

Luke Matthew Sutton

unread,
Jul 7, 2008, 9:41:57 PM7/7/08
to sinatrarb
This gets even stranger. If I try to do that, I get

#<NoMethodError: undefined method `enable' for main:Object>

That seems bizarre to me, since I thought enable/set/set_option etc
were all mixed into Object along with the get/post methods?

It may be something daft my app is doing, so I'm going to try it out
with a fresh app.

On Jul 8, 10:26 am, "Blake Mizerany" <blake.mizer...@gmail.com> wrote:
> enable :sessions
>
> should be the only thing you need to get started.
>
> On Mon, Jul 7, 2008 at 4:28 PM, Luke Matthew Sutton <luke.sut...@gmail.com>
> blake.mizer...@gmail.com

Luke Matthew Sutton

unread,
Jul 7, 2008, 9:44:44 PM7/7/08
to sinatrarb
Even with a very simple app I get the same problem

<pre><code>
require 'rubygems'
require 'sinatra'

enable :sessions

get "/" do
session["test"] = true
session.inspect
end
</code></pre>

undefined method `enable' for main:Object (NoMethodError)

Doh!

Luke Matthew Sutton

unread,
Jul 7, 2008, 9:52:27 PM7/7/08
to sinatrarb
I just unpacked the Sinatra 0.2.2 gem and it doesn't have an enable
method defined. So it's an old version on rubyforge?

Do I need to be running from edge?

blake.m...@gmail.com

unread,
Jul 7, 2008, 11:34:10 PM7/7/08
to sina...@googlegroups.com
yes. You'll need be running from edge


--
Blake Mizerany
blake.m...@gmail.com

Luke Matthew Sutton

unread,
Jul 8, 2008, 1:11:39 AM7/8/08
to sinatrarb
After much futzing about, this fixed the issue for me. YAy!

Thank you.

P.S. Sinatra is awesome… I'll def be using it for more projects at
work.

On Jul 8, 12:34 pm, blake.mizer...@gmail.com wrote:
> yes. You'll need be running from edge
>
> blake.mizer...@gmail.com
Reply all
Reply to author
Forward
0 new messages