mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-22 07:04:09 +01:00
Fix #1223 for the single tag and single dependency case in the REST API
This commit is contained in:
parent
eb2f071c80
commit
960326efb4
3 changed files with 48 additions and 23 deletions
|
|
@ -299,24 +299,13 @@ class Todo < ActiveRecord::Base
|
|||
# XML API fixups
|
||||
def predecessor_dependencies=(params)
|
||||
value = params[:predecessor]
|
||||
return if value.nil?
|
||||
|
||||
if !value.nil?
|
||||
if value.class == Array
|
||||
value.each do |ele|
|
||||
if ele.is_a? String
|
||||
add_predecessor(self.user.todos.find_by_id(ele.to_i)) unless ele.blank?
|
||||
else
|
||||
predecessor_dependencies.build(value)
|
||||
end
|
||||
end
|
||||
else
|
||||
if ele.is_a? String
|
||||
add_predecessor(self.user.todos.find_by_id(ele.to_i)) unless ele.blank?
|
||||
else
|
||||
predecessor_dependencies.build(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
# for multiple dependencies, value will be an array of id's, but for a single dependency,
|
||||
# value will be a string. In that case convert to array
|
||||
value = [value] unless value.class == Array
|
||||
|
||||
value.each { |ele| add_predecessor(self.user.todos.find_by_id(ele.to_i)) unless ele.blank? }
|
||||
end
|
||||
|
||||
alias_method :original_context=, :context=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue