I am trying to do an AJAX call with Rails. The call is to the change_profile action in my controller. The contents of this action are as follows:
def change_profile
@test = params[:test]
puts "AAAAAAA #{@test}"
respond_to do |format|
format.html
format.js
end
render(:text => "FINISHED THE AJAX REQUEST")
end
When I call this, however, the Rails console says:
ActionView::MissingTemplate (Missing template main/change_profile ....
I don't understand why this is happening. Since I'm rendering text, shouldn't it know not to try to find the template and just render the text?
When left without a {}, the respond_to block looks for a file called change_profile.erb.js or some other change_profile.xxx.js. Add your code within the respond_to block
def change_profile
@test = params[:test]
puts "AAAAAAA #{@test}"
respond_to do |format|
format.html
format.js {
render :text => "FINISHED THE AJAX REQUEST"
}
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With