lib/card/action.rb in wagn-1.14.2 vs lib/card/action.rb in wagn-1.14.3
- old
+ new
@@ -12,11 +12,11 @@
end
end
end
def nth_action index
- Action.where("(draft IS NULL OR draft = :draft) AND card_id = ':id'", {:draft=>false, :id=>id})[index-1]
+ Action.where("draft is not true AND card_id = #{id}").order(:id).limit(1).offset(index-1).first
end
def revision action
# a "revision" refers to the state of all tracked fields at the time of a given action
if action.is_a? Integer
@@ -113,10 +113,11 @@
def new_value_for(field)
ch = changes.find_by_field(field) and ch.value
end
def change_for(field)
- changes.where('card_changes.field = ?', field)
+ field_integer = ( field.is_a?(Integer) ? field : Card::TRACKED_FIELDS.index(field.to_s) )
+ changes.where 'card_changes.field = ?', field_integer
end
def new_type?
new_value_for(:type_id)