Guest User

Untitled

a guest
May 23rd, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. THe code:
  2.  
  3. def facebook_inspiration_link(impact)
  4. Rails.logger.debug "Facebook_inspiration_link"
  5. Rails.logger.debug "Impact: #{impact.to_yaml}"
  6. Rails.logger.debug "Impact Metrics: #{impact.impact_metrics.to_yaml}"
  7. Rails.logger.debug "First Impact Metric: #{impact.impact_metrics.first.to_yaml}"
  8. Rails.logger.debug "Metric: #{impact.impact_metrics.first.metric.to_yaml}"
  9. unless impact.user == current_user
  10. link_to('I did this too »', facebook_action_url(impact.impact_metrics.first.metric, :inspiration_id => impact.id))
  11. end
  12. end
  13.  
  14.  
  15.  
  16. The log output:
  17.  
  18. Facebook_inspiration_link
  19. Impact: --- !ruby/object:Impact
  20. attributes:
  21. created_at: 2008-11-11 19:38:47
  22. impacted_type:
  23. updated_at: 2008-11-11 19:38:47
  24. impacted_id:
  25. story:
  26. kudos_count: "0"
  27. headline: I saved a paper cup today by bringing a refillable one
  28. id: "1777"
  29. user_id: "11593"
  30. date_accomplished: 2008-11-11 19:38:47
  31. facebook: "1"
  32. inspiration_id:
  33. attributes_cache: {}
  34.  
  35. impact_metrics:
  36. - !ruby/object:ImpactMetric
  37. attributes:
  38. impact_id: "1777"
  39. quantity: "6.00"
  40. id: "1612"
  41. user_id: "11593"
  42. metric_id: 809
  43. attributes_cache: {}
  44.  
  45. changed_attributes:
  46. metric_id: 404 <-----here's the wackiness, the metric_id has changed
  47. user: !ruby/object:User
  48. attributes:
  49. salt:
  50. city: ""
  51. newsfeed_id: "12208"
  52. big_blue_color: main
  53. imported_id:
  54. facebook_id: "1632912393"
  55. created_at: 2008-11-11 17:13:48
  56. zip: ""
  57. latitude:
  58. image_file_name:
  59. crypted_password:
  60. remember_token_expires_at:
  61. is_email_notifiable: "1"
  62. country: ""
  63. private_last_name_setting: "0"
  64. last_activity:
  65. image_file_size:
  66. session_key: 2e56da614ca2ada819f19366-1632912393
  67. updated_at: 2008-11-12 11:45:41
  68. username: ""
  69. role: "0"
  70. image_content_type:
  71. id: "11593"
  72. long_description:
  73. reset_email: "0"
  74. private_location_setting: "0"
  75. last_name: ""
  76. is_verified: "0"
  77. remember_token:
  78. parent_id:
  79. imported_from:
  80. date_of_birth:
  81. description: ""
  82. longitude:
  83. private_profile_setting: "0"
  84. facebook_points: "75"
  85. first_name: ""
  86. email: ""
  87. email_validation_key:
  88. state: ""
  89. affiliated_org_id:
  90. attributes_cache: {}
  91.  
  92. Impact Metrics: ---
  93. - !ruby/object:ImpactMetric
  94. attributes:
  95. impact_id: "1777"
  96. quantity: "6.00"
  97. id: "1612"
  98. user_id: "11593"
  99. metric_id: 809
  100. attributes_cache: {}
  101.  
  102. changed_attributes:
  103. metric_id: 404
  104. First Impact Metric: --- !ruby/object:ImpactMetric
  105. attributes:
  106. impact_id: "1777"
  107. quantity: "6.00"
  108. id: "1612"
  109. user_id: "11593"
  110. metric_id: 809
  111. attributes_cache: {}
  112.  
  113. changed_attributes:
  114. metric_id: 404
  115. Metric Load (0.000179) SELECT * FROM `metrics` WHERE (`metrics`.`id` = 809)
  116. Metric: --- <--- And so not metric is found, even though in script/console there is a metric, and in the DB directly too
Add Comment
Please, Sign In to add comment