Skip to content

Instantly share code, notes, and snippets.

@rubystar
Last active December 11, 2015 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubystar/4594784 to your computer and use it in GitHub Desktop.
Save rubystar/4594784 to your computer and use it in GitHub Desktop.
Rails fails to save joining model
[venkatab@pnwsdes053 redzone]$ rails c
/home/local/PENNYWISE/venkatab/.rvm/gems/ruby-1.9.3-p194@redzone/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require': iconv will be deprecated in the future, use String#encode instead.
Loading development environment (Rails 3.2.11)
[1] pry(main)> gt = c.geo_targets.build({"name" => "Venkat is testitnee"})
NameError: undefined local variable or method `c' for main:Object
from (pry):1:in `__pry__'
[2] pry(main)> c = Campaign.first
Campaign Load (642.4ms) SELECT `campaigns`.* FROM `campaigns` ORDER BY campaigns.name LIMIT 1
EXPLAIN (0.3ms) EXPLAIN SELECT `campaigns`.* FROM `campaigns` ORDER BY campaigns.name LIMIT 1
EXPLAIN for: SELECT `campaigns`.* FROM `campaigns` ORDER BY campaigns.name LIMIT 1
+----+-------------+-----------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+------+---------------+------+---------+------+------+----------------+
| 1 | SIMPLE | campaigns | ALL | NULL | NULL | NULL | NULL | 4152 | Using filesort |
+----+-------------+-----------+------+---------------+------+---------+------+------+----------------+
1 row in set (0.00 sec)
=> #<Campaign id: 3625, name: " Trass", advertiser_id: 241, created_at: "2011-09-01 08:33:52", updated_at: "2012-10-12 08:23:17", start_date: "2011-09-01", end_date: "2011-10-03", media_buyer_id: 1507, delta: true, department_id: 1, premium_volume: "premium", order_name: "Acanthion-Tauli-Telic-2011-09", legacy_custom_dimensions: "--- \n- !map:HashWithIndifferentAccess \n name: \"Cus...", geo_targeting_strategy: "dart", slug: "trace911", override_department_id: nil, hourly_rate: nil, push_paymo_changes: false, paymo_project_id: nil, account_manager_id: 204, billing_basis: "Ras", ad_server: "Daze", custom_dimensions_1_label: "Custom #1", custom_dimensions_2_label: "Custom #2", custom_dimensions_3_label: "Custom #3">
[3] pry(main)> gt = c.geo_targets.build({"name" => "Venkat is testitnee"})
=> #<GeoTarget id: nil, name: "Venkat is testitnee", code: nil, geo_type: nil, created_at: nil, updated_at: nil, dart_id: nil, fully_qualified_name: nil, description: nil, rank: nil, slug: nil, delta: true, type: "DartGeoTarget", netacuity_id: nil>
[4] pry(main)> gt.save!
(0.1ms) BEGIN
SQL (49.1ms) INSERT INTO `geo_targets` (`code`, `created_at`, `dart_id`, `delta`, `description`, `fully_qualified_name`, `geo_type`, `name`, `netacuity_id`, `rank`, `slug`, `type`, `updated_at`) VALUES (NULL, '2013-01-22 18:38:07', NULL, 1, NULL, NULL, NULL, 'Venkat is testitnee', NULL, NULL, NULL, 'DartGeoTarget', '2013-01-22 18:38:07')
(71.4ms) COMMIT
=> true
[5] pry(main)> gt = c.geo_targets.create({"name" => "Venkat is testitneein"})
(0.1ms) BEGIN
SQL (0.4ms) INSERT INTO `geo_targets` (`code`, `created_at`, `dart_id`, `delta`, `description`, `fully_qualified_name`, `geo_type`, `name`, `netacuity_id`, `rank`, `slug`, `type`, `updated_at`) VALUES (NULL, '2013-01-22 18:38:21', NULL, 1, NULL, NULL, NULL, 'Venkat is testitneein', NULL, NULL, NULL, 'DartGeoTarget', '2013-01-22 18:38:21')
SQL (27.4ms) INSERT INTO `campaign_geo_targets` (`campaign_id`, `created_at`, `geo_target_id`, `updated_at`) VALUES (3625, '2013-01-22 18:38:21', 37252, '2013-01-22 18:38:21')
(58.1ms) COMMIT
=> #<GeoTarget id: 37252, name: "Venkat is testitneein", code: nil, geo_type: nil, created_at: "2013-01-22 13:08:21", updated_at: "2013-01-22 13:08:21", dart_id: nil, fully_qualified_name: nil, description: nil, rank: nil, slug: nil, delta: true, type: "DartGeoTarget", netacuity_id: nil>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment