Rails 3 possible bug in Routing

On Sat, Feb 20, 2010 at 9:19 PM, Daniel G.
[email protected]wrote:

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.

-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
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
  2. explicitly set the :html => { :method => :post } in form_for so it
    doesn’t make wrong guesses
  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

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

On Sun, Feb 21, 2010 at 6:11 AM, Daniel G.
[email protected]wrote:

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:

Good luck,

-Conrad

Thanks…

On Sat, Aug 6, 2011 at 2:52 AM, john paul [email protected] wrote:

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