Hi everyone,
I am a bit confused with xhr? and respond_to.
I have the folloing code in my view to update the ‘emails’ ID
link_to_remote(image_tag(“refresh”), :update => “emails”,
:url => { :action => “list_emails” })
in the controller side i have somthing like :
[…]
respond_to do |type|
type.html { render :action ‘list_emails’ }
type.js { render :partial => ‘list_emails’ }
end
[…]
The partial returns html code such as
[…]
- email1
In my controller functional test
I do
[…]
xhr :get,:list_emails
assert_select “ul”
[…]
But `assert_select’ did not find anything.
However if i changed my controller action (remove the respond_to and
replace with xhr?)
[…]
if request.xhr?
render :partial => ‘list_emails’
else
render :action ‘list_emails’
end
[…]
Then the assertion works perfectly.
Am i missing something ? Are not we supossed to migrate to the
respond_to structure ? wht would be the recommendation for this
situation ? stick with xhr?
thanks a lot
-sebastien