'redirect_to' taking infinite loop

Hi,

The following controller method taking me into infinite loop. Once the
update action completes I want to reload the ‘index’ page. May I know
why it is going into infinite loop?

def update
Device.find_by_id( params[:device_id] ).driver = (
params[:driver_id] == 0 ) ? nil : Driver.find_by_id( params[:driver_id]
)

 redirect_to :action => :index, :tab => 'limo'

end

Thanks,
Ajit

Hello, Ajit,

First of all params incoming with the requests are strings. You expect
it
to be Fixnum (0), rather than a String (‘0’). params[:anything] cannot
be
== 0, because if it is “zero”, it will be received as “0” in the
controller. Just use this in the conditional and report with whether it
succeeded or is still failing, in which case I’d ask you to provide
INDEX
action of the same controller, and before filters that affect
Devices#index
action (replaced 0 with ‘0’):

def update
Device.find_by_id( params[:device_id] ).driver = (
params[:driver_id] == ‘0’ ) ? nil : Driver.find_by_id(
params[:driver_id]
)

2012/8/1 Ajit T. [email protected]


You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit https://groups.google.com/groups/opt_out.


Pagarbiai,
Gintautas

On 1 August 2012 12:57, Ajit T. [email protected] wrote:

 redirect_to :action => :index, :tab => 'limo'

end

Not an answer to the problem but you do not seem to be saving anything
in the update action, which is a bit unusual.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs