This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BACKGROUND: | |
We're changing the offer form a bit to have a new set of fields for each line item in the offer. Therefore we need to change the set of columns in the database table that stores these line items. Old data will need to be modified to fit the new format. This document outlines an algorithm for modifying the old data into the new format. | |
EXISTING COLUMNS | |
* description | |
* quantity | |
* part_price (unit price per part) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionView::Template::Error (undefined method `fed_date' for nil:NilClass): | |
3: = @state.name | |
4: (₦ #{number_with_delimiter(@fa, :delimiter => ',')}) | |
5: .small | |
6: = "#{@state.federal_allocations.order("fed_date DESC").last.fed_date.strftime("%m-%Y")} - #{@state.federal_allocations.order("fed_date DESC").first.fed_date.strftime("%m-%Y")}" | |
7: .clear | |
8: | |
9: #text | |
app/views/projects/modal.haml:6:in `_app_views_projects_modal_haml___1854547266735518192_2509573200' | |
app/controllers/projects_controller.rb:9:in `block (2 levels) in modal' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def can_compute_performance?(start_date, end_date) | |
- !checking? && (balances.count(:select => 'distinct period', :conditions => { :period => (start_date..end_date)}) > 1) | |
+ has_at_least_one_period = balances.count( | |
+ :select => 'distinct period', | |
+ :conditions => {:period => (start_date..end_date)} | |
+ ) > 1 | |
+ is_not_checking = !checking? | |
+ | |
+ is_not_checking && has_at_least_one_period | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CURRENT | |
Cycle | |
can_receive_return? -> delegate | |
returned_product? -> delegate | |
receive_return -> delegate | |
decisions: | |
[Null] | |
Skip | |
can_receive_return? -> false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
validates :tag_id, :uniqueness => {:scope => :post_id} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(...):005:0> klass.columns_hash["tag"].text? | |
NoMethodError: undefined method `text?' for nil:NilClass | |
... | |
irb(...):006:0> klass.columns_hash["tag_id"].text? | |
=> false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> tagging = Tagging.create(:post => Post.first, :tag => Tag.first) | |
(rdb:1) irb | |
irb(...):001:0> klass | |
=> Tagging(id: integer, tag_id: integer, post_id: integer, created_at: datetime, updated_at: datetime) | |
irb(...):002:0> attribute | |
=> :tag | |
irb(...):004:0> klass.columns_hash.keys | |
=> ["id", "tag_id", "post_id", "created_at", "updated_at"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 def build_relation(klass, table, attribute, value) #:nodoc: | |
56 debugger; column = klass.columns_hash[attribute.to_s] | |
57 value = column.limit ? value.to_s.mb_chars[0, column.limit] : value.to_s if column.text? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> p = Post.create(:name => "foo") | |
=> #<Post id: 1, name: "foo", created_at: "2011-08-11 20:03:12", updated_at: "2011-08-11 20:03:12"> | |
> t = Tag.create(:name => "bar") | |
=> #<Tag id: 1, name: "bar", created_at: "2011-08-11 20:03:20", updated_at: "2011-08-11 20:03:20"> | |
> tagging = Tagging.create(:post => p, :tag => t) | |
NoMethodError: undefined method `text?' for nil:NilClass | |
from ... lib/active_support/whiny_nil.rb:48:in `method_missing' | |
from ... lib/active_record/validations/uniqueness.rb:57:in `build_relation' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rake db:migrate | |
$ rails console --debug |