Via! in ruby

Can someone explain the use ! in the following Ruby example:

 def show @article = Article.find(params[:id]) respond_to do |format| format.html { render :layout => ! request.xhr? } end end 

thanks

+1
source share
2 answers

This is just a logical not .

 request.xhr? => true !request.xhr? => false 
+5
source

If you do not want to display the layout when the request comes from AJAX. then use :layout => !request.xhr?

+3
source

Source: https://habr.com/ru/post/920389/


All Articles