[Rails-core] Re: redesigning mass attribute assignment (activerecord 3.0?)

2009-05-26 Thread cainlevy
After playing with a reimagined version of attr_accessible/ attr_protected in my plugin, I'm much happier with the model-side filtering approach. I think it allows for more interesting and useful defaults. Since this API is to live only as a plugin for a bit, I'm unsure whether this thread is the

[Rails-core] Re: redesigning mass attribute assignment (activerecord 3.0?)

2009-05-26 Thread cainlevy
ax reads better than "attributes = params[:user].slice(...)", but that alone isn't enough reason to change an API. On May 26, 3:42 am, Hongli Lai wrote: > On May 24, 8:25 am, Michael Koziarski wrote: > > > > > cainlevy wrote: > > > Which points to an inter

[Rails-core] Re: redesigning mass attribute assignment (activerecord 3.0?)

2009-05-25 Thread cainlevy
I've put the core assign() method into a plugin. Feedback is always desired. http://github.com/cainlevy/mass_assignment On May 24, 1:33 am, cainlevy wrote: > Hey Matt, I did some thinkng about this and I'm not sure if the > simpler use cases are actually simpler with attr_a

[Rails-core] Re: redesigning mass attribute assignment (activerecord 3.0?)

2009-05-24 Thread cainlevy
ention the maintenance headache when adding a   > new field... > > --Matt Jones > > On May 24, 2009, at 12:16 AM, cainlevy wrote: > > > > > Ok, primary ticket: > >https://rails.lighthouseapp.com/projects/8994/tickets/2704-allow-call... > > > An

[Rails-core] Re: redesigning mass attribute assignment (activerecord 3.0?)

2009-05-23 Thread cainlevy
Ok, primary ticket: https://rails.lighthouseapp.com/projects/8994/tickets/2704-allow-calltime-list-of-allowed-attributes-for-mass-assignment And the bonus round: https://rails.lighthouseapp.com/projects/8994/tickets/2705-deprecate-attr_accessible-attr_protected On May 23, 5:40 pm, cainlevy

[Rails-core] Re: redesigning mass attribute assignment (activerecord 3.0?)

2009-05-23 Thread cainlevy
e evaluated independently. On May 23, 4:40 pm, Damian Janowski wrote: > On Fri, May 22, 2009 at 11:42 PM, cainlevy wrote: > > We're all familiar with attr_accessible and attr_protected. These methods > > provide rudimentary support from malicious mass assignment ... when peop

[Rails-core] redesigning mass attribute assignment (activerecord 3.0?)

2009-05-22 Thread cainlevy
Hello! I'd like to refactor the code for mass assignment to support a new security paradigm, but figured that I might save some time getting feedback from the gatekeepers of the code. :-) We're all familiar with attr_accessible and attr_protected. These methods provide rudimentary support from ma

[Rails-core] Re: Built associations don't know their parent. Why not?

2009-04-25 Thread cainlevy
d to writing bi-directional association validations in my home-grown validation library. Granted, I've always had to set the "reverse" association manually which looks a little shoddy in my controllers, but the key to making it all work was: http://github.com/cai

[Rails-core] Re: accepts_nested_attributes_for patch request

2009-04-06 Thread cainlevy
"I can agree that its dangerous to destroy attributes in this means, but for my case there is no other way" That's a pretty strong claim. Could you explain a little? On Apr 5, 6:10 pm, Josh wrote: > I can agree that its dangerous to destroy attributes in this means, > but for my case there is n

[Rails-core] Patch Review Request: #1892 moves ids inside the nested attributes hash

2009-02-05 Thread cainlevy
==The Problem: The parameter structure in the current implementation of nested attributes does support both modification and replacement of existing has_one records. ==The Solution: Move ids inside the hash. That is, instead of: @pirate.birds_attributes = { '12' => { :name => 'Polly' },

[Rails-core] Re: another attempt at nested mass assignment (pluginized)

2008-12-14 Thread cainlevy
iated. I'm feeling very positive about this approach at the moment. -Lance On Dec 13, 2:18 am, cainlevy wrote: > Hey, this turned out alright! > > http://github.com/cainlevy/complex-form-examples/tree/cainlevy > > Some notes on my implementation: > * I made a point to show t

[Rails-core] Re: another attempt at nested mass assignment (pluginized)

2008-12-13 Thread cainlevy
Hey, this turned out alright! http://github.com/cainlevy/complex-form-examples/tree/cainlevy Some notes on my implementation: * I made a point to show that everything works without JavaScript. But it would be easy to sprinkle some JS in to hide the template row and clone it for "add an

[Rails-core] another attempt at nested mass assignment (pluginized)

2008-12-12 Thread cainlevy
After reading previous discussions on the topic ([1] and [2]), I have tried to take the best ideas and create a working plugin that adds nested mass assignment to ActiveRecord. Please see http://github.com/cainlevy/nested_assignment/tree/master. My paradigm parameters are: { # singular

[Rails-core] association assignment with delayed database access

2008-12-11 Thread cainlevy
Hello, I've been digging into the discussion around nested mass assignment, and am trying my hand at a plugin that adds what I consider the optimal model behavior. But I'm running into a solid problem trying to use association proxies without modifying anything in the database. My take is that t

[Rails-core] load_association_classes can block migrations (and slow down script/runner)

2008-11-28 Thread cainlevy
Hello, I ran into a problem recently that was previously reported as ticket #802 [1]. The issue, briefly, occurs when a model definition runs a class method (such as for a plugin) that checks table information. In this case, loading the model requires the database table to already exist. Running

[Rails-core] Re: Patch Review: #576 adds a :load option to ActiveRecord

2008-08-22 Thread cainlevy
On Aug 21, 8:35 am, Frederick Cheung <[EMAIL PROTECTED]> wrote: > On 21 Aug 2008, at 16:15, cainlevy wrote: > > > > > You can actually call the preload_associations method whenever you > > want. > > I know, I wrote it :-) Hey thanks! Love it. :-) > >

[Rails-core] Re: Patch Review: #576 adds a :load option to ActiveRecord

2008-08-21 Thread cainlevy
You can actually call the preload_associations method whenever you want. It's not public, though, so you need to use send() -- perhaps that should change? On Aug 20, 6:08 pm, Frederick Cheung <[EMAIL PROTECTED]> wrote: > On Aug 18, 10:40 pm, cainlevy <[EMAIL PROTECTED]> wro

[Rails-core] Patch Review: #576 adds a :load option to ActiveRecord

2008-08-20 Thread cainlevy
I like the preloading functionality in ActiveRecord. Can we expose an API option for it? I know it's important to be careful with adding AR options, but I believe that adding a :load option would complement the existing :include and :joins options as follows: * :include names associations that sh