calling another rjs file in an if condition

   I have a controller action like below.This def is called by a
def edit_service_desk_status_after_transfer
      if params[:transfer_reason].empty?
        #This is used in the :failure of submit_to_remote
        @sd_ticket = ServiceDeskTicket.find(params[:sd_id])
        ActiveRecord::Base.transaction do
          @sd_status_history =
          @sd_status_history.service_desk_ticket_id =
          @sd_status_history.service_desk_status_id =

        end #end of transaction
     if params[:page]=='search_sd_ticket'
         render :update do |page|
       #The below portion i dont want to execute if the above condition

In the above what i am trying to do is if the if condition
if params[:page]=='search_sd_ticket' is satisfied call another rjs
instead of the default rjs file
edit_service_desk_status_after_transfer.rjs .The above is not working
.How can I do that..And I need not execute code after the if , if the
condition is ok..Just load another rjs which has the code to replace
some other divs rather than the default rjs does


You can render an alternate RJS file with render.

render :controller => :foo, :action => :alternate_bar

You can also just use an if/else in the RJS file.

     Thanks for your reply.It worked

  The above problem solved .But this too related to that problem .So I
am posting in the same place.I have One more question related to this..I
am calling the above function from different views but with differnt
params..For example from one view page when i call this through
submit_to_remote a particular param params[:page] is not passing .But
from one other place I have to pass this param.Will this create any
problem.Or this anything related to route.rb?Why i am asking this I had
already this working..But as I said earlier last day i called this same
function using submit_to_remote from another view with a param
params[:page]="search_sd_ticket" and checked it in an if else ..So that
is working..But the alredy working code now shows a failure from the
other view?What might be the reason?Can't i pass or not pass differnet
params to the same function?

Thanks in advance

It will be easier to help if you let us know what the failure is.

To answer your base question, the controller does not know or care
where the request comes from. It will inspect the query string (via
params), find the appropriate data to satisfy the request, and
generate the response regardless of who asked for it or how (data
problems excepted obviously).

One possibility would be that the rjs you generate may be trying to
update a specific element on the page that only exists in one of the
places that you call the action. You can code around that by using
the or by simply rendering the results and
using :update on the ajax call. The choice lies in how many updates
you make in your ajax response.