diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index eb3c2d21..5a695e71 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -338,7 +338,7 @@ class ProjectsController < ApplicationController default_context_name = p['default_context_name'] p.delete('default_context_name') - unless default_context_name.blank? + if default_context_name.present? default_context = current_user.contexts.where(:name => default_context_name).first_or_create p['default_context_id'] = default_context.id end diff --git a/app/controllers/recurring_todos_controller.rb b/app/controllers/recurring_todos_controller.rb index 854b20b4..08642e55 100644 --- a/app/controllers/recurring_todos_controller.rb +++ b/app/controllers/recurring_todos_controller.rb @@ -129,7 +129,7 @@ class RecurringTodosController < ApplicationController end @saved = @recurring_todo.save - unless (@saved == false) || p.tag_list.blank? + if @saved && p.tag_list.present? @recurring_todo.tag_with(p.tag_list) @recurring_todo.tags.reload end @@ -255,14 +255,14 @@ class RecurringTodosController < ApplicationController end def project_specified_by_name? - return false unless @attributes['project_id'].blank? + return false if @attributes['project_id'].present? return false if project_name.blank? return false if project_name == 'None' true end def context_specified_by_name? - return false unless @attributes['context_id'].blank? + return false if @attributes['context_id'].present? return false if context_name.blank? true end diff --git a/app/controllers/todos/todo_create_params_helper.rb b/app/controllers/todos/todo_create_params_helper.rb index 22cf6274..f896a5f7 100644 --- a/app/controllers/todos/todo_create_params_helper.rb +++ b/app/controllers/todos/todo_create_params_helper.rb @@ -102,14 +102,14 @@ module Todos end def project_specified_by_name? - return false unless @attributes['project_id'].blank? + return false if @attributes['project_id'].present? return false if project_name.blank? return false if project_name == 'None' true end def context_specified_by_name? - return false unless @attributes['context_id'].blank? + return false if @attributes['context_id'].present? return false if context_name.blank? true end diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 551ed1be..3690ca34 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -74,7 +74,7 @@ class TodosController < ApplicationController def create @source_view = params['_source_view'] || 'todo' @default_context = current_user.contexts.where(:name => params['default_context_name']).first - @default_project = current_user.projects.where(:name => params['default_project_name']).first unless params['default_project_name'].blank? + @default_project = current_user.projects.where(:name => params['default_project_name']).first if params['default_project_name'].present? @tag_name = params['_tag_name'] @@ -157,7 +157,7 @@ class TodosController < ApplicationController # first build all todos and check if they would validate on save params[:todo][:multiple_todos].split("\n").map do |line| - unless line.blank? #ignore blank lines + if line.present? #ignore blank lines @todo = current_user.todos.build({:description => line, :context_id => p.context_id, :project_id => p.project_id}) validates &&= @todo.valid? @@ -175,8 +175,8 @@ class TodosController < ApplicationController todo.add_predecessor(@predecessor) todo.block! end - - todo.tag_with(tag_list) unless (@saved == false) || tag_list.blank? + + todo.tag_with(tag_list) if @saved && tag_list.present? @todos << todo @not_done_todos << todo if p.new_context_created || p.new_project_created @@ -203,7 +203,7 @@ class TodosController < ApplicationController else @multiple_error = @todos.size > 0 ? "" : t('todos.next_action_needed') @saved = false - @default_tags = current_user.projects.where(:name => @initial_project_name).default_tags unless @initial_project_name.blank? + @default_tags = current_user.projects.where(:name => @initial_project_name).default_tags if @initial_project_name.present? end @status_message = @todos.size > 1 ? t('todos.added_new_next_action_plural') : t('todos.added_new_next_action_singular') diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 82b5f351..503583ff 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -30,10 +30,10 @@ module ProjectsHelper next_project = content_tag(:li, link_to_project_mobile(@next_project, "6", @next_project.shortened_name), :class=>"next") if @next_project return content_tag(:ul, "#{prev_project}#{next_project}".html_safe, :class=>"next-prev-project") end - + def project_summary(project) project_description = '' - project_description += Tracks::Utils.render_text( project.description ) unless project.description.blank? + project_description += Tracks::Utils.render_text( project.description ) if project.description.present? project_description += content_tag(:p, "#{count_undone_todos_phrase(p)}. #{t('projects.project_state', :state => project.state)}".html_safe ) diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 50ab53ef..fe75c760 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -408,7 +408,7 @@ module TodosHelper end def format_ical_notes(notes) - unless notes.nil? || notes.blank? + if notes.present? split_notes = notes.split(/\n/) joined_notes = split_notes.join("\\n") end @@ -426,7 +426,7 @@ module TodosHelper def render_animation(animation) html = "" animation.each do |step| - unless step.blank? + if step.present? html += step + "({ go: function() {\r\n" end end diff --git a/app/models/todo.rb b/app/models/todo.rb index 5602fdc5..eea0e1da 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -299,7 +299,7 @@ class Todo < ActiveRecord::Base return unless predecessor_list.kind_of? String @predecessor_array=predecessor_list.split(",").inject([]) do |list, todo_id| - predecessor = self.user.todos.find( todo_id.to_i ) unless todo_id.blank? + predecessor = self.user.todos.find( todo_id.to_i ) if todo_id.present? list << predecessor unless predecessor.nil? list end @@ -341,7 +341,7 @@ class Todo < ActiveRecord::Base # value will be a string. In that case convert to array deps = [deps] unless deps.class == Array - deps.each { |dep| self.add_predecessor(self.user.todos.find(dep.to_i)) unless dep.blank? } + deps.each { |dep| self.add_predecessor(self.user.todos.find(dep.to_i)) if dep.present? } end alias_method :original_context=, :context= diff --git a/app/services/todo_from_rich_message.rb b/app/services/todo_from_rich_message.rb index 6efc1c8d..f919b0bb 100644 --- a/app/services/todo_from_rich_message.rb +++ b/app/services/todo_from_rich_message.rb @@ -16,7 +16,7 @@ class TodoFromRichMessage project = extractor.project context_id = default_context_id - unless context.blank? + if context.present? found_context = user.contexts.active.where("name like ?", "%#{context}%").first found_context = user.contexts.where("name like ?", "%#{context}%").first if !found_context context_id = found_context.id if found_context @@ -27,7 +27,7 @@ class TodoFromRichMessage end project_id = nil - unless project.blank? + if project.present? if project[0..3].downcase == "new:" found_project = user.projects.build found_project.name = project[4..259].strip diff --git a/app/views/projects/_project_settings.html.erb b/app/views/projects/_project_settings.html.erb index 86311954..5244e949 100644 --- a/app/views/projects/_project_settings.html.erb +++ b/app/views/projects/_project_settings.html.erb @@ -17,7 +17,7 @@ <% end -%> <%= link_to_edit_project(project, t('projects.edit_project_settings')) %> - <% unless project.description.blank? -%> + <% if project.description.present? -%>