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
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
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 Teli <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
> 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
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
Pagarbiai,
Gintautas
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
On 1 August 2012 12:57, Ajit Teli <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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'' > endNot an answer to the problem but you do not seem to be saving anything in the update action, which is a bit unusual. Colin> > > Thanks, > Ajit > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.