activerecord associations do not act like a collection anymore, so convert to array first

before using map, collect, etc.
This commit is contained in:
Reinier Balt 2014-04-12 21:21:40 +02:00
parent 85cfa1c366
commit 49a09f36e8
4 changed files with 9 additions and 9 deletions

View file

@ -238,7 +238,7 @@ module TodosHelper
def remote_toggle_checkbox(todo=@todo)
check_box_tag("mark_complete_#{todo.id}", toggle_check_todo_path(todo), todo.completed?, :class => 'item-checkbox',
:title => todo.pending? ? t('todos.blocked_by', :predecessors => todo.uncompleted_predecessors.map(&:description).join(', ')) : "", :readonly => todo.pending?)
:title => todo.pending? ? t('todos.blocked_by', :predecessors => todo.uncompleted_predecessors.to_a.map(&:description).join(', ')) : "", :readonly => todo.pending?)
end
def remote_mobile_checkbox(todo=@todo)
@ -251,7 +251,7 @@ module TodosHelper
if todo.completed?
content_tag(:span, {:class => :grey}) { format_date( todo.completed_at ) }
elsif todo.pending?
title = t('todos.depends_on')+ ": " + todo.uncompleted_predecessors.map(&:description).join(', ')
title = t('todos.depends_on')+ ": " + todo.uncompleted_predecessors.to_a.map(&:description).join(', ')
content_tag(:a, {:title => title}) { content_tag(:span, {:class => :orange}) { t('todos.pending') } }
elsif todo.deferred?
show_date( todo.show_from )
@ -263,7 +263,7 @@ module TodosHelper
def successors_span(todo=@todo)
unless todo.pending_successors.empty?
pending_count = todo.pending_successors.count
title = "#{t('todos.has_x_pending', :count => pending_count)}: #{todo.pending_successors.map(&:description).join(', ')}"
title = "#{t('todos.has_x_pending', :count => pending_count)}: #{todo.pending_successors.to_a.map(&:description).join(', ')}"
image_tag( 'successor_off.png', :width=>'10', :height=>'16', :border=>'0', :title => title )
end
end
@ -277,7 +277,7 @@ module TodosHelper
end
def tag_list_text(todo=@todo)
todo.tags.join(', ')
todo.tags.to_a.join(', ')
end
def tag_span (tag, mobile=false)

View file

@ -159,7 +159,7 @@ function block_predecessors(next_steps) {
function regenerate_predecessor_family(next_steps) {
<%
if @predecessors
parents = @predecessors
parents = @predecessors.to_a
until parents.empty?
parent = parents.pop
parents += parent.predecessors -%>

View file

@ -125,7 +125,7 @@ function update_predecessors(next_steps) {
function regenerate_predecessor_family() {
<%
parents = @todo.predecessors
parents = @todo.predecessors.to_a
until parents.empty?
parent = parents.pop
parents += parent.predecessors

View file

@ -9,10 +9,10 @@ module IsTaggable
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings do
def to_s
self.map(&:name).sort.join(Tag::JOIN_DELIMITER)
self.to_a.map(&:name).sort.join(Tag::JOIN_DELIMITER)
end
def all_except_starred
self.reject{|tag| tag.name == Todo::STARRED_TAG_NAME}
self.to_a.reject{|tag| tag.name == Todo::STARRED_TAG_NAME}
end
end
@ -31,7 +31,7 @@ module IsTaggable
# Transactions may not be ideal for you here; be aware.
Tag.transaction do
current = tags.map(&:name)
current = tags.to_a.map(&:name)
_add_tags(list - current)
_remove_tags(current - list)
end