Maybe I should make clear that I changed the Session implementation
back to its original state after finding what caused the PUT method
being attached. Looks like you were still assuming my Session inherits
from ActiveRecord::Base. It was just for testing purpose to see if it
works correctly with an ActiveRecord model.
If you attended the Exploring Rails 3 Online conference, it was clearly
discussed
that this feature (i.e. ActiveModel) is ready for 3rd party ORM
builders.
Initially looking at the problem suggested a routing bug since as
stated in my first message the output in the log file contained:
Started POST “/login” for 127.0.0.1
even so submitting the login form actually used _method => :put which
in Rails 2.x would have been reported as:
Processing … (for 127.0.0.1) [PUT]
further investigation (after my first post) made clear that the
problem was not related to routing but was due to the way form_for
determines which method to use if not specified.
Since I was NOT using ActiveRecord::Base my Session was NOT responding
to :new_record? which caused form_for adding _method => :put
Now what is the takeaway message here?
Session should implement a form of new_record? if you want to use
it with form_for OR
explicitly set the :html => { :method => :post } in form_for so it
doesn’t make wrong guesses
it may be worth considering changing the logging to actually read:
Started PUT “/login” for 127.0.0.1 IFF the _method parameter is set
to :put
Yes thank you, I read Yehuda’s articles before but was not thinking
of :new_record? when I was working with my Session class. So I had to
learn it the hard way.
further investigation (after my first post) made clear that the
3) it may be worth considering changing the logging to actually read:
Started PUT “/login” for 127.0.0.1 IFF the _method parameter is set
to :put
In short, you’re trying to make non ArctiveRecord objects behave like
ActiveRecord. Thus, I would recommend reading the very good write-up
by Yehuda K., a Rails core member, because your object, as it stands,
isn’t fully compatible with Rails 3, more specifically, ActionPack: