I have the following models:
class Merchant
acts_as_authentic
has_one :store
accepts_nested_attributes_for :store
end
class Store
belongs_to :merchant
end
I am using authlogic_oauth gem for Twitter authentication. While registration I save the Merchant and the Store model. If I disable the oauth authentication both models are saved. When ever I enable the oauth authentication only Merchant instance is saved.
After spending some time looking at the authlogic_oauth gem code I think found the culprit. The authlogic_oauth gem stores the ActiveRecord attributes in the session during oauth calls. But it does not store the attributes of the associations.
# authlogic_oauth : lib/authlogic_oauth/acts_as_authentic.rb
def save(perform_validation = true, &block)
if perform_validation && block_given? && redirecting_to_oauth_server?
# My comment: Any nested attributes are not saved in the session
session_class.controller.session[:authlogic_oauth_attributes] = attributes.reject!{|k, v| v.blank?}
# some code
end
# some code
end
I can hack the gem code but I am wondering if there is a better solution.