I have the following in my application_controller.rb
def layout
unless request.subdomain.empty? && current_user.nil?
self.class.layout 'admin'
end
end
It seems the code above it’s not working. But when I do the following, it does work.
def layout
unless request.subdomain.empty?
unless current_user.nil?
self.class.layout 'admin'
end
end
end
I would like to simplify the code by removing one unless statement. How could I do that?
unless somethingis equivalent toif !something. In your case, that would beHowever, you want
Using boolean algebra (De Morgan rule), you can rewrite that to
Using
unless