I have an interesting (well, to me anyway LOL) and perhaps philosophical issue with the :dirty plug and using a model instance with a join.
Consider the following overly simplified example: Get the ID of one order from today, and the customer's name by joining it. Order.plugin :dirty one_order = Order .where(date: Date.today) .join(:customers, id: :customer_id) .select(:id, :customers__name) .first puts one_order[:name] # "Bob Johnson" -- customer name This works fine. `one_order` is technically an `Order` instance but I'm not so sure it really is. The problem with the dirty plugin comes up when the non-order fields are assigned something: one_order[:name] = "Testing" # undefined method 'name' for <#Order> This happens because name isn't actually an Order column, so when it tries to get the value, there's no method available to provide it. The error happens in the change_column_value method of the dirty plugin. It seems to me as though the dirty plugin should verify that it's checking valid columns for that model. Is it worth updating the dirty plugin to check that assignments are actually made to model columns, or is this a case of using a model instance in the wrong way? (to be honest, I think it's a little of both). -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/65bff2ec-4aad-4302-ad16-a52faaf03c75%40googlegroups.com.
