1

I have the following in session_store.rb. I'm running Ruby 1.8.7 and rails 3.1.0.rc4

require 'dm-rails/session_store'
ActionDispatch::Session::DataMapperStore = Rails::DataMapper::SessionStore
Contendable::Application.config.session_store :data_mapper_store

I get the following output when making a request against the server:

[2011-10-19 22:07:14] INFO  WEBrick 1.3.1
[2011-10-19 22:07:14] INFO  ruby 1.8.7 (2011-06-30) [i686-darwin10.7.4]
[2011-10-19 22:07:14] INFO  WEBrick::HTTPServer#start: pid=24805 port=3000


Started GET "/" for 127.0.0.1 at Wed Oct 19 22:07:27 -0700 2011
  SQL (21.975ms)  SELECT "id", "session_id", "data", "updated_at" FROM "sessions" WHERE "session_id" = '7ecd5903df96a6d26cbbc69e6d397ce9' ORDER BY "id" LIMIT 1

ArgumentError (wrong number of arguments (4 for 3)):
  • Please post the rest of the error message and the method in your code that it corresponds to. – Jordan Running Oct 20 '11 at 05:28
  • I may patch this, I think I know what it is. Rails 3.1 changed the arguments in the session store. I'll get back to you and submit a pull request. – d11wtq Oct 20 '11 at 07:13

1 Answers1

0

Fixed:

https://github.com/datamapper/dm-rails/pull/28

You'll either have to use my fork from git (in your Gemfile) for now, or add a monkey patch to fix it.

d11wtq
  • 34,788
  • 19
  • 120
  • 195
  • Actually, now I'm getting this: uninitialized constant Rails::DataMapper::SessionStore::ENV_SESSION_OPTIONS_KEY – Zach Tratar Oct 20 '11 at 07:59
  • Ugh. Let's see. Will get back to you. – d11wtq Oct 20 '11 at 08:17
  • Can you try it now and get back to me, please? :) (It's the branch 'bugfix/rails-3.1-sessions', but I guess you found that) – d11wtq Oct 20 '11 at 08:20
  • Now I get: gems/dm-rails-1.2.0/lib/dm-rails/session_store.rb:30: uninitialized constant Rails::Rack::Session (NameError) – Zach Tratar Oct 20 '11 at 09:58
  • Sorry (if you haven't guessed, I can't test it :P)... and now? I think this should do it. I'm trying to make sure it won't break in Rails 3.0 projects ;) – d11wtq Oct 20 '11 at 10:08
  • Now I get this: dm-rails-1.2.0/lib/dm-rails/session_store.rb:30: uninitialized constant Rails::DataMapper::SessionStore::ENV_SESSION_OPTIONS_KEY (NameError) – Zach Tratar Oct 20 '11 at 10:24
  • Hmmm, I'm gonna have to set up a little Rails app, which I was hoping to avoid. I may not get to this until tomorrow, sorry. Feel free to take a look at the diff in my changes and try and debug it, however. I'm definitely setting that constant o_O – d11wtq Oct 20 '11 at 10:27
  • I just made another change that may fix that. Looks like `||=` doesn't work with constants. Not sure why. – d11wtq Oct 20 '11 at 10:39