Coniditional loading of rjs files?

ok I have been struggling with this - seems very straight forward?

given a controller game_controller with a method/action receive_move
that gets called by an ajax event on the client/browser I can
‘automatically’ load an rjs file receive_move.rjs, but if I try to do
this in code it always appends .rhtml to the file name?

the code that works but always loads the same rjs file

when called from receive_move action this loads up receive_move.rjs

respond_to do |format|
format.js
end

this does not work

looking at the log it is appending .rhtml to the file name

if standard_move then
respond_to do |format|
format.js { render :action => ‘receive_move.rjs’ }
end
else
respond_to do |format|
format.js { render :action => ‘receive_move_non_standard.rjs’ }
end
end

found the above code on the net, maybe the approach is just plain wrong?
Note that I can just code all of my rjs commands directly in the
controller without issue?

running rails ‘1.2.3’

any help would be appreciated, Thanks!

On 10/15/07, Jesse H. [email protected] wrote:

but if I try to do
this in code it always appends .rhtml to the file name?

end
Have you tried leaving the ‘.rjs’ off of your :action options?


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

Try to create two new actions in controller: receive_move and
receive_move_non_standard, and render them
like render :action => :receive_move_non_standard

Rick Denatale wrote:

Have you tried leaving the ‘.rjs’ off of your :action options?
My blog on Ruby
http://talklikeaduck.denhaven2.com/

yes, I tried both ways
render :action => ‘receive_move_non_standard.rjs’ tries to load
receive_move_non_standard.rjs.rhtml

and
render :action => ‘receive_move_non_standard’ tries to load
receive_move_non_standard.rhtml

and both ways generate a ActionController::MissingTemplate in the log
with the file name it is trying to load

Igor K. wrote:

Try to create two new actions in controller: receive_move and
receive_move_non_standard, and render them
like render :action => :receive_move_non_standard

excellent! that worked like a charm!

Thanks Igor!

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