For review: Nested params, like :accessible.

This is the patch that I would create as stated in this thread:

http://groups.google.com/group/rubyonrails-core/browse_thread/thread/3c61e00916c365e5/ad1d4e40da933243

I will take some time one of the next few days to turn my plugin into a patch.

Well obviously it took me longer than I had anticipated, but the current state is at:

http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1202-add-attributes-writer-method-for-an-association

Cheers,

Eloy

Ok just a little bump, because:

A) I have updated my patch with better docs, but more importantly I also added #acts_like_hash? to Hash and AS::OrderedHash.

There are now 4 not NestedParams related patches in the “what’s in the patch => general patches” section.

Should I create new tickets for them? Because I have the feeling it will otherwise get ignored by people that are not interested

in a fully functional :accessible.

B) There are updated docs for NestedParams, thanks to Manfred Stienstra, and it’s updated for current edge Rails.

Cheers,

Eloy

Ok just a little bump, because:

I'm flat out with 2.2 related stuff myself, but this, or something
like it, is definitely on the roadmap for 2.3

Ok just a little bump, because:

I'm flat out with 2.2 related stuff myself, but this, or something
like it, is definitely on the roadmap for 2.3

Gotcha. I'll wait with any further discussing until 2.2 has been released :slight_smile:

Cheers,
Eloy

Hi Elloy!
Thanks for useful plugin.
I whan ask, Why new version distribute not by plugin?
How i can implement it in my project
And another moment, when new records add dinamyc by JS new_id not
changed! I see this fiture in attribute_fu plugin
http://github.com/giraffesoft/attribute_fu/tree/master
Why you dont use this fiture?

Sorry for my poor english.

Hi Faust,

First of all, sorry for the late response.

Thanks for useful plugin.
I whan ask, Why new version distribute not by plugin?

About the plugin, it actually was a plugin that we used internally at Fingertips.
Then this thread came up on the list:
http://groups.google.com/group/rubyonrails-core/browse_thread/thread/3c61e00916c365e5/487d7a95b0f82886?hl=en
And after some discussion I decided to make a patch out of it,
with some of the adjustments as suggested in that thread.

How i can implement it in my project

If you want to use it right now, you could apply the patch
to a vendor'ed rails checkout. _If_ I find some spare time
I might backport the adjustments to the plugin and release that for the time being,
but there are some patches to the AR::Associations internals etc,
so it I have no idea right now how fast/when this would be done…

And another moment, when new records add dinamyc by JS new_id not
changed! I see this fiture in attribute_fu plugin
http://github.com/giraffesoft/attribute_fu/tree/master
Why you dont use this fiture?

Could you maybe link to the actual code you are referring too?

If you are talking about generating new record form entries from JS,
then please also check the above mentioned thread, as I have done
something like that. But basically it's fairly simple, so I don't really
see the need for any helpers there.

Cheers,
Eloy

Thanks for response.

I told about this:
http://github.com/giraffesoft/attribute_fu/tree/master/lib/attribute_fu/associated_form_helper.rb

def fields_for_associated(associated, *args, &block)
      conf = args.last.is_a?(Hash) ? args.last : {}
      associated_name = extract_option_or_class_name(conf, :name,
associated)
      name = associated_base_name associated_name

      unless associated.new_record?
        name << "[#{associated.new_record? ? 'new' : associated.id}]"
      else
        @new_objects ||= {}
        @new_objects[associated_name] ||= -1 # we want naming to start
at 0
        identifier = !conf.nil? && conf[:javascript] ? '#{number}' :
@new_objects[associated_name]+=1

        name << "[new][#{identifier}]"
      end

      @template.fields_for(name, *args.unshift(associated), &block)
    end

HI dinamicly compose object name [new][#{identifier}] OR #{number}(for
JS) OR @new_objects[associated_name]+=1 for(new records but not JS)

I dont see fiture like this in
http://github.com/alloy/rails/tree/97f8b4fe8f1d8c53203023b19718ffa442622877/actionpack/lib/action_view/helpers/form_helper.rb

I do create composited ID's for new records in #new_child_record on
line 851,
which is called from line 843.

However like I said in the previous email, there's no specific JS helper
because I haven't needed it and in the example I made it was easy
enough.

So I think it's better that someone who would _actually_ use this and
have
a _real life_ example to create a patch for this.
Otherwise it wouldn't be good code IMO.

Cheers,
Eloy