Permalink
Browse files

removing attribute_fu yay!

  • Loading branch information...
Bringo committed Nov 1, 2011
1 parent bb5a2cf commit a66c6eb3dcf6a2fa2270c1d00e5777291e5ed067
Showing with 44 additions and 2,191 deletions.
  1. +25 −13 app/models/asset.rb
  2. +19 −11 app/models/instantiation.rb
  3. +0 −1 vendor/plugins/attribute_fu/.gitignore
  4. +0 −20 vendor/plugins/attribute_fu/MIT-LICENSE
  5. +0 −115 vendor/plugins/attribute_fu/README
  6. +0 −22 vendor/plugins/attribute_fu/Rakefile
  7. +0 −2 vendor/plugins/attribute_fu/init.rb
  8. +0 −255 vendor/plugins/attribute_fu/javascripts/jquery.template.js
  9. +0 −2 vendor/plugins/attribute_fu/lib/attribute_fu.rb
  10. +0 −139 vendor/plugins/attribute_fu/lib/attribute_fu/associated_form_helper.rb
  11. +0 −124 vendor/plugins/attribute_fu/lib/attribute_fu/associations.rb
  12. +0 −4 vendor/plugins/attribute_fu/tasks/attribute_fu_tasks.rake
  13. +0 −10 vendor/plugins/attribute_fu/test/Rakefile
  14. +0 −10 vendor/plugins/attribute_fu/test/app/controllers/application.rb
  15. +0 −3 vendor/plugins/attribute_fu/test/app/helpers/application_helper.rb
  16. +0 −8 vendor/plugins/attribute_fu/test/app/models/comment.rb
  17. +0 −3 vendor/plugins/attribute_fu/test/app/models/photo.rb
  18. +0 −97 vendor/plugins/attribute_fu/test/config/boot.rb
  19. +0 −15 vendor/plugins/attribute_fu/test/config/database.yml
  20. +0 −15 vendor/plugins/attribute_fu/test/config/environment.rb
  21. +0 −18 vendor/plugins/attribute_fu/test/config/environments/development.rb
  22. +0 −22 vendor/plugins/attribute_fu/test/config/environments/test.rb
  23. +0 −35 vendor/plugins/attribute_fu/test/config/routes.rb
  24. +0 −14 vendor/plugins/attribute_fu/test/db/migrate/001_create_photos.rb
  25. +0 −15 vendor/plugins/attribute_fu/test/db/migrate/002_create_comments.rb
  26. +0 −29 vendor/plugins/attribute_fu/test/db/schema.rb
  27. +0 −3 vendor/plugins/attribute_fu/test/script/console
  28. +0 −3 vendor/plugins/attribute_fu/test/script/destroy
  29. +0 −3 vendor/plugins/attribute_fu/test/script/generate
  30. +0 −3 vendor/plugins/attribute_fu/test/script/server
  31. +0 −6 vendor/plugins/attribute_fu/test/test/test_helper.rb
  32. +0 −375 vendor/plugins/attribute_fu/test/test/unit/associated_form_helper_test.rb
  33. +0 −6 vendor/plugins/attribute_fu/test/test/unit/comment_test.rb
  34. +0 −149 vendor/plugins/attribute_fu/test/test/unit/photo_test.rb
  35. +0 −3 vendor/plugins/attribute_fu/test/vendor/plugins/shoulda/init.rb
  36. +0 −20 vendor/plugins/attribute_fu/test/vendor/plugins/shoulda/lib/shoulda.rb
  37. +0 −338 vendor/plugins/attribute_fu/test/vendor/plugins/shoulda/lib/shoulda/active_record_helpers.rb
  38. +0 −143 vendor/plugins/attribute_fu/test/vendor/plugins/shoulda/lib/shoulda/context.rb
  39. +0 −119 vendor/plugins/attribute_fu/test/vendor/plugins/shoulda/lib/shoulda/general.rb
  40. +0 −17 vendor/plugins/attribute_fu/test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
  41. +0 −1 vendor/plugins/attribute_fu/uninstall.rb
View
@@ -20,25 +20,37 @@ class Asset < ActiveRecord::Base
UUID_REGEX = /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/
- has_many :identifiers, :dependent => :destroy, :attributes => true
- has_many :titles, :dependent => :destroy, :attributes => true
+ has_many :identifiers, :dependent => :destroy
+ has_many :titles, :dependent => :destroy
has_and_belongs_to_many :subjects
- has_many :descriptions, :dependent => :destroy, :attributes => true
+ has_many :descriptions, :dependent => :destroy
has_and_belongs_to_many :genres
- has_many :relations, :dependent => :destroy, :attributes => true
- has_many :coverages, :dependent => :destroy, :attributes => true
+ has_many :relations, :dependent => :destroy
+ has_many :coverages, :dependent => :destroy
has_and_belongs_to_many :audience_levels
has_and_belongs_to_many :audience_ratings
- has_many :creators, :dependent => :destroy, :attributes => true
- has_many :contributors, :dependent => :destroy, :attributes => true
- has_many :publishers, :dependent => :destroy, :attributes => true
- has_many :rights_summaries, :dependent => :destroy, :attributes => true
- has_many :instantiations, :dependent => :destroy
- has_many :extensions, :dependent => :destroy, :attributes => true
- has_many :versions, :dependent => :delete_all
- has_many :asset_dates, :dependent => :destroy, :attributes => true
+ has_many :creators, :dependent => :destroy
+ has_many :contributors, :dependent => :destroy
+ has_many :publishers, :dependent => :destroy
+ has_many :rights_summaries, :dependent => :destroy
+ has_many :instantiations, :dependent => :destroy
+ has_many :extensions, :dependent => :destroy
+ has_many :versions, :dependent => :delete_all
+ has_many :asset_dates, :dependent => :destroy
stampable
+ accepts_nested_attributes_for :identifiers, :allow_destroy => true
+ accepts_nested_attributes_for :titles, :allow_destroy => true
+ accepts_nested_attributes_for :descriptions, :allow_destroy => true
+ accepts_nested_attributes_for :relations, :allow_destroy => true
+ accepts_nested_attributes_for :coverages, :allow_destroy => true
+ accepts_nested_attributes_for :creators, :allow_destroy => true
+ accepts_nested_attributes_for :contributors, :allow_destroy => true
+ accepts_nested_attributes_for :publishers, :allow_destroy => true
+ accepts_nested_attributes_for :rights_summaries, :allow_destroy => true
+ accepts_nested_attributes_for :extensions, :allow_destroy => true
+ accepts_nested_attributes_for :asset_dates, :allow_destroy => true
+
validates_size_of :identifiers, :minimum => 1, :message => "must have at least one entry"
validates_size_of :titles, :minimum => 1, :message => "must have at least one entry"
@@ -1,28 +1,36 @@
class Instantiation < ActiveRecord::Base
include PbcoreXmlElement
include ActionView::Helpers::NumberHelper
+
+ before_create :generate_uuid
+ after_destroy :delete_files
+
+ attr_protected :asset, :asset_id, :uuid
belongs_to :asset
- has_many :format_ids, :dependent => :destroy, :attributes => true
- has_many :instantiation_dates, :dependent => :destroy, :attributes => true
- has_many :instantiation_dimensions, :dependent => :destroy, :attributes => true
belongs_to :format
belongs_to :instantiation_media_type
belongs_to :instantiation_generation
belongs_to :instantiation_color
- has_many :essence_tracks, :dependent => :destroy, :attributes => true
- has_many :annotations, :dependent => :destroy, :attributes => true
- has_many :borrowings, :dependent => :destroy
+
+ has_many :format_ids, :dependent => :destroy
+ has_many :instantiation_dates, :dependent => :destroy
+ has_many :instantiation_dimensions, :dependent => :destroy
+ has_many :essence_tracks, :dependent => :destroy
+ has_many :annotations, :dependent => :destroy
+ has_many :borrowings, :dependent => :destroy
+
stampable
-
- attr_protected :asset, :asset_id, :uuid
+
+ accepts_nested_attributes_for :format_ids, :allow_destroy => true
+ accepts_nested_attributes_for :instantiation_dates, :allow_destroy => true
+ accepts_nested_attributes_for :instantiation_dimensions, :allow_destroy => true
+ accepts_nested_attributes_for :essence_tracks, :allow_destroy => true
+ accepts_nested_attributes_for :annotations, :allow_destroy => true
validates_presence_of :format_location
validates_size_of :format_ids, :minimum => 1
- before_create :generate_uuid
- after_destroy :delete_files
-
xml_attributes "startTime", "endTime", "timeAnnotation"
xml_subelements "instantiationIdentifier", :format_ids
to_xml_elt do |obj|
@@ -1 +0,0 @@
-.DS_Store
@@ -1,20 +0,0 @@
-Copyright (c) 2008 James Golick
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,115 +0,0 @@
-= AttributeFu
-
-
-Creating multi-model forms is amazingly easy with AttributeFu.
-
-= Get It!
-
- $ piston import http://svn.jamesgolick.com/attribute_fu/tags/stable vendor/plugins/attribute_fu
-
-= Conventions
-
-attribute_fu requires the fewest keystrokes if you follow certain conventions.
-
-* The partial that contains your associated model's form is expected to be called _class_name.template_ext
- (e.g. the partial for your Task model would be called _task.html.erb)
-* The DOM element that contains the form for your model should have the CSS class .class_name
- (e.g. the CSS class for your Task would be .task)
-* The DOM element that contains all of the rendered forms should have the DOM ID #class_name
- (e.g. the DOM ID of the container of your Task forms would be #tasks)
- <i>Note: This is only relevant if using the add_associated_link method.</i>
-
-= Example
-
-In this example, you'll build a form for a Project model, in which a list of associated (has_many) tasks can be edited.
-
-The first thing you need to do is enable attributes on the association.
-
- class Project < ActiveRecord::Base
- has_many :tasks, :attributes => true
- end
-
-Instances of Project will now respond to task_attributes, whose format is as follows:
-
- @project.task_attributes = {
- @project.tasks.first.id => {:title => "A new title for an existing task"},
- :new => {
- "0" => {:title => "A new task"}
- }
- }
-
-Any tasks that already exist in that collection, and are not included in the hash, as supplied to task_attributes, will be removed from the association when saved. Most of the time, the form helpers should take care of building that hash for you, though.
-
-== Form Helpers
-
-If you follow certain conventions, rendering your associated model's form elements is incredibly simple. The partial should have the name of the associated element's type, and look like a regular old form partial (no messy fields_for calls, or any nonsense like that).
-
- ## _task.html.erb
- <div class="task">
- <label>Title</label>
- <%= f.text_field :title %>
- </div>
-
-Then, in your parent element's form, call the render_associated_form method on the form builder, with the collection of elements you'd like to render as the only argument.
-
- ## _form.html.erb
- <%= f.render_associated_form(@project.tasks) %>
-
-That call will render the partial named _task.html.erb with each element in the supplied collection of tasks, wrapping the partial in a form builder (fields_for) with all the necessary arguments to produce a hash that will satisfy the task_attributes method.
-
-You may want to add a few blank tasks to the bottom of your form; no need to do that in the controller anymore.
-
- <%= f.render_associated_form(@project.tasks, :new => 3) %>
-
-Since this is Web2.0, no form would be complete without some DHTML add and remove buttons. Fortunately, there are some nifty helpers to create them for us. Simply calling remove_link on the form builder in your _task partial will do the trick.
-
- ## _task.html.erb
- <div class="task">
- <label>Title</label>
- <%= f.text_field :title %>
- <%= f.remove_link "remove" %>
- </div>
-
-Creating the add button is equally simple. The add_associated_link helper will do all of the heavy lifting for you.
-
- ## _form.html.erb
- <%= f.add_associated_link "Add New Task", @project.tasks.build %>
-
-That's all you have to do to create a multi-model form with attribute_fu!
-
-== Discarding Blank Child Models
-
-If you want to show a bunch of blank child model forms at the bottom of your form, but you only want to save the ones that are filled out, you can use the discard_if option. It accepts either a proc:
-
- class Project < ActiveRecord::Base
- has_many :tasks, :attributes => true, :discard_if => proc { |task| task.title.blank? }
- end
-
-...or a symbol...
-
- class Project < ActiveRecord::Base
- has_many :tasks, :attributes => true, :discard_if => :blank?
- end
-
- class Task < ActiveRecord::Base
- def blank?
- title.blank?
- end
- end
-
-Using a symbol allows you to keep code DRYer if you are using that routine in more than one place. Both of those examples, however, would have the same effect.
-
-= Updates
-
-Come join the discussion on the {mailing list}[link:http://groups.google.com/group/attribute_fu]
-
-Updates will be available {here}[http://jamesgolick.com/attribute_fu]
-
-
-== Credits
-
-attribute_fu was created, and is maintained by {James Golick}[http://jamesgolick.com].
-
-
-
-Copyright (c) 2007 James Golick, GiraffeSoft Inc., released under the MIT license
@@ -1,22 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the attribute_fu plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the attribute_fu plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'AttributeFu'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
@@ -1,2 +0,0 @@
-ActiveRecord::Base.class_eval { include AttributeFu::Associations }
-ActionView::Helpers::FormBuilder.class_eval { include AttributeFu::AssociatedFormHelper }
Oops, something went wrong.

0 comments on commit a66c6eb

Please sign in to comment.