simo
simo

Reputation: 24560

Using ! in Ruby

Can some one please explain the usage ! 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

Upvotes: 1

Views: 197

Answers (2)

Shamith c
Shamith c

Reputation: 3739

If you don't want to render a layout when the request comes from AJAX. then use :layout => !request.xhr?

Upvotes: 3

Flexoid
Flexoid

Reputation: 4245

It's simply logical not.

request.xhr?
=> true

!request.xhr?
=> false

Upvotes: 5

Related Questions