ich einen BereichWie jeder auf Spielraum für keinen Hash zurückgeben
class HistoricRefinancing < ActiveRecord::Base
scope :consult_historic_refin, -> (refinancing_id) {
HistoricRefinancing.where("refinancing_id = ? ", "#{refinancing_id}") }
end
haben und ich es hier genannt (refinancings_controller.rb):
def cancel_refinancing
@hist_refin = HistoricRefinancing.consult_historic_refin(params[:refinancing_id])
@hist_refin.authorization.update_columns(situation: 1)
end
Aber haben zwei Probleme, erste wenn ich Puts auf @hist_refin tun, kehren diese:
-------
HistoricRefinancing Load (3.1ms) SELECT "HISTORIC==_REFINANCINGS".* FROM "HISTORIC_REFINANCINGS" WHERE (refinancing_id = '17')
#<HistoricRefinancing:0x007f616c515cc8>
Und dieser Fehler:
NoMethodError - undefined method `authorization' for #<HistoricRefinancing::ActiveRecord_Relation:0x007f617b1d35d8>:
Meine Beziehungen ist richtig, Autorisierung viele Refinanzierungen hat, refinancig zulassungs gehört, hat historische Refinanzierung (entspricht authorization_id, aber ich brauchte Änderung der Name) authorization_origin_id, refinancing_id und authorization_new_id
Alles, was ich will, ist Spalte Wechselsituation für 1, sondern nur für die Refinanzierungen. Wie geht es, bitte?
Als Hilfe Sie:
def cancel_refinancing
@hist_refin = HistoricRefinancing.consult_historic_refin(params[:refinancing_id])
@hist_refin.map{|hr| hr.authorization.update_attributes(situation: 1) }
end
Und dieser Fehler, den ich erhalten:
NoMethodError - undefined method `update_attributes' for nil:NilClass:
= (
nennen FYI sollten Sie 'HistoricRefinancing.where werden (refinancing_id: refinancing_id)' – meagar