Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

plugins and attributes_with_quotes on update

#1343

How I find it (on example with globalize and better_nested_set plugins):

On using these 2 plugins, update on translation is wrong (it updates "base language" with wrong value), and be sure, this bug not only globalize relative :)

Both of these plugins handle update actions, and some stuff for it, like "attributes_with_quotes", and both of them not want to write some fields with some conditions. What I have now - globalize override the attributes_with_quotes to remove "translatable" fields, if language not "base", and store there fields on own table. In the same time better_nested_set want to remove own fields (left and right borders), to check them and update later if necessary. Both plugins have a copy of base attributes_with_quotes, with own conditions, and I lose some changes on attributes, will get only last changes with attributes, like - only nested_set attributes will be deleted, so globalize attributes will be wrong.

I fixed this with changes in plugins, but think that this is little wrong, because any other plugins will have same story if they use attributes_with_quotes method to make changes in attributes (maybe exists some pretty way to do this, but like we see - 2 popolar plugins use "bad" way to make theirs things).

I suggest small changes in ActiveRecord::base.update (2489 line here) -

def update(attribute_names = @attributes.keys) quoted_attributes = attributes_with_quotes(false, false, attribute_names) ....

to make something like here (just a quickly idea) -

def update(attribute_names = @attributes.keys) attribs = attributes_to_update quoted_attributes = quote_hash_values(attribs) ....

this will allow to other plugins handle attributes_to_update action, and make its own things with copy of attributes. We should get attributes that was changed with all plugins that want some changes, not only last plugin's, like we see now.

Reported by ru_rails · November 7th, 2008 @ 03:53 PM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Pratik
    Pratik
    • State changed from new to incomplete

    Patch please!

    March 12th, 2009 @ 03:59 PM

  2. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  3. rails
    rails
    • State changed from incomplete to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    May 4th, 2011 @ 01:00 AM

  4. rails
    rails
    • State changed from open to stale

    May 4th, 2011 @ 01:00 AM