Skip to content

Instantly share code, notes, and snippets.

@shiroginne
Last active December 22, 2015 23:39
Show Gist options
  • Save shiroginne/6548096 to your computer and use it in GitHub Desktop.
Save shiroginne/6548096 to your computer and use it in GitHub Desktop.
#application.rb
require "active_record/railtie"
#pry
[3] pry(#<Api::CheckoutsController>)> Api::CheckoutData.new
=> #<Api::CheckoutData id: nil, token: nil, shop_id: nil, transaction_type: nil, created_at: nil, updated_at: nil>
[4] pry(#<Api::CheckoutsController>)> Api::CheckoutData.new({})
NoMethodError: undefined method `safe_constantize' for nil:NilClass
from /Users/aeldreath/.rvm/gems/ruby-2.0.0-p247@global/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:175:in `subclass_from_attrs'
#checkout_data.rb
class Api::CheckoutData < ActiveRecord::Base
has_one :order
has_one :shop
has_one :settings, class_name: 'CheckoutSettings'
has_one :customer, class_name: 'Address'
accepts_nested_attributes_for :customer, :settings, :order
end
#schema.rb
create_table "checkout_data", force: true do |t|
t.string "token"
t.integer "shop_id"
t.string "transaction_type"
t.datetime "created_at"
t.datetime "updated_at"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment