style: if ! changed by unless

- if ! changed by unless as it is more readable
- !object.blank? is equivalent to object.present?, also more readable
This commit is contained in:
Ana 2016-08-06 00:57:07 +02:00
parent 96155eb87f
commit 7e5d20c89d
18 changed files with 27 additions and 28 deletions

View file

@ -103,7 +103,7 @@ module Admin
comment.commentable = @event
comment.user_id = current_user.id
comment.save!
if !params[:parent].nil?
unless params[:parent].nil?
comment.move_to_child_of(params[:parent])
end
@ -202,7 +202,7 @@ module Admin
def get_event
@event = @conference.program.events.find(params[:id])
if !@event
unless @event
redirect_to admin_conference_program_events_path(conference_id: @conference.short_title),
error: 'Error! Could not find event!'
return

View file

@ -67,7 +67,7 @@ module Admin
def destroy
if can? :destroy, @question
# Do not delete global questions
if !@question.global
unless @question.global
# Delete question and its answers
begin

View file

@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base
rescue_from CanCan::AccessDenied do |exception|
Rails.logger.debug "Access denied on #{exception.action} #{exception.subject.inspect}"
message = exception.message
message << ' Maybe you need to sign in?' if !current_user
message << ' Maybe you need to sign in?' unless current_user
redirect_to root_path, alert: message
end

View file

@ -52,7 +52,7 @@ class ConferenceRegistrationsController < ApplicationController
ahoy.track 'Registered', title: 'New registration'
# Sign in the new user
if !current_user
unless current_user
sign_in(@registration.user)
end
@ -96,7 +96,7 @@ class ConferenceRegistrationsController < ApplicationController
def set_registration
@registration = Registration.find_by(conference: @conference, user: current_user)
if !@registration
unless @registration
redirect_to new_conference_conference_registration_path(@conference.short_title),
error: "Can't find a registration for #{@conference.title} for you. Please register."
end