This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG | ||
| |
MIT-LICENSE | ||
| |
README | ||
| |
Rakefile | ||
| |
init.rb | ||
| |
install.rb | ||
| |
lib/ | ||
| |
nested_models.gemspec | ||
| |
tasks/ | ||
| |
test/ | ||
| |
uninstall.rb |
README
NestedModels
============
Until now ActiveRecord wasn't great with associations massive assignment (aka multi model forms handling).
This plugin allow to deal with this kind of problems.
Example
=======
class Project < ActiveRecord::Base
has_many :tasks, :accessible => true
end
# CREATE
project = Project.create :name => "NestedModels", :tasks => [
{ :name => "Implement", :description => "Implement me" }
]
project.name # => "NestedModels"
project.taks.size # => 1
# UPDATE
project.update_attributes :tasks => [
{ :id => 1, :name => "Implement me" },
{ :name => "Evangelize", :description => "Tell to your friends!" }
]
project.tasks.size # => 2
project.tasks.first.name # => "Implement me"
project.tasks.last.name # => "Evangelize"
# DESTROY
project.update_attributes :tasks => [
{ :id => 1, :destroy => true }
]
project.tasks.size # => 1
Note: you can define your own destroy flag:
class Milestone < ActiveRecord::Base
set_accessible_association_destroy_flag "destroy_me"
end
project.update_attributes :milestones => [
{ :id => 1, :destroy_me => true }
]
Copyright (c) 2009 Luca Guidi, released under the MIT license








