Ruby on Rails Wednesday, August 1, 2012

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@ruby-forum.com>
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment