My Question:
What should the correct structure be? I have tried redesign this several times but keep getting tight-coupling issues.
Relevant Info:
I am writing a new endpoint for some third party software. It will receive a payload that I am then passing into a static method of my Subscription class. From there I want to do a look-up of the payload related subscription, establish an instance of it, then perform an update based off the rest of my information on my class. I am running into an error that is saying the following: undefined method update for ActiveRecording::Association::HasOneAssociation
EndPointController:
class Api::V2::EndpointController < Api::V5::BaseController
def connect
data = decode(request.body.read)
Subscription.static_method(data)
end
end
Subscription Model:
class Subscription < ActiveRecord::Base
def self.static_method(data)
@subscription = Subscription.find_by_id(data.subscription_id)
@subscription.update(data)
end
end
Subscription Controller:
class SubscriptionsController < ApplicationController
def update
#execute update
end
end
Aucun commentaire:
Enregistrer un commentaire