Rails 3 possible bug in Routing

What are you trying to prove here?

I’m not using ActiveRecord and my Session class IS NOT inheriting from

ActiveRecord::Base either

I’m trying to prove to you that ActiveModel works without ActiveRecord::Base. It

works so much so I’m building ActiveRecord style interface to work with Maglev.

Next, in your initial e-mail to the mailing list, you mentioned that there was a possible

bug in Rails 3 routing. What does this have to do with the possible bug in routing?

-Conrad

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

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?

  1. Session should implement a form of new_record? if you want to use

it with form_for OR

  1. explicitly set the :html => { :method => :post } in form_for so it

doesn’t make wrong guesses

  1. 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 Katz, a Rails core member, because your object, as it stands,

isn’t fully compatible with Rails 3, more specifically, ActionPack:

http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord

Good luck,

-Conrad

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.

Hi sir,

     I have create one rails application ,am creating user form and
using the session (logged on) and (logged out) , i dont know how its
used am newipe in rails pls help

regards,
john

Hi sir,

 I have create one rails application ,am creating user form  and

using the session (logged on) and (logged out) , i dont know how its

used am newipe in rails pls help

regards,

john

John, I would recommend reading the following:

http://ruby.railstutorial.org/chapters/sign-in-sign-out#top

Good luck,

-Conrad

Thanks…