Permalink
Browse files

updating gemspec, readme, Gemfile, RSpec, and rvmrc

  • Loading branch information...
1 parent 013a558 commit 4ab18684176aefed0c6d11cf3be8b36441865902 @ryanb committed Feb 15, 2011
View
@@ -1,2 +1,3 @@
-pkg/*
-*.gem
+*.swp
+**/*.swp
+*.gem
View
1 .rspec
@@ -0,0 +1 @@
+--color
View
1 .rvmrc
@@ -0,0 +1 @@
+rvm use 1.9.2@nested_form --create
View
@@ -1,4 +1,3 @@
-source :gemcutter
+source "http://rubygems.org"
-# Specify your gem's dependencies in nested_form.gemspec
-gemspec
+gemspec
View
@@ -65,17 +65,15 @@ GEM
rake (>= 0.8.4)
thor (~> 0.14.0)
rake (0.8.7)
- rr (1.0.0)
- rspec (2.0.0)
- rspec-core (= 2.0.0)
- rspec-expectations (= 2.0.0)
- rspec-mocks (= 2.0.0)
- rspec-core (2.0.0)
- rspec-expectations (2.0.0)
- diff-lcs (>= 1.1.2)
- rspec-mocks (2.0.0)
- rspec-core (= 2.0.0)
- rspec-expectations (= 2.0.0)
+ rr (0.10.11)
+ rspec (2.1.0)
+ rspec-core (~> 2.1.0)
+ rspec-expectations (~> 2.1.0)
+ rspec-mocks (~> 2.1.0)
+ rspec-core (2.1.0)
+ rspec-expectations (2.1.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.1.0)
thor (0.14.3)
treetop (1.4.8)
polyglot (>= 0.3.1)
@@ -85,8 +83,7 @@ PLATFORMS
ruby
DEPENDENCIES
- bundler (>= 1.0.0.rc.5)
nested_form!
rails (~> 3.0.0)
- rr
- rspec (~> 2.0.0.beta.22)
+ rr (~> 0.10.11)
+ rspec (~> 2.1.0)
View
@@ -1,4 +1,4 @@
-Copyright (c) 2010 Ryan Bates
+Copyright (c) 2011 Ryan Bates
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ 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.
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -4,11 +4,12 @@ A Rails gem to conveniently manage multiple nested models in a single form. It d
To learn more about how this works under the hood: http://blog.madebydna.com/dynamic-nested-forms-in-rails-3-with-the-nest
+
== Install
Add it to your Gemfile
- gem "nested_form", :git => "git://github.com/madebydna/nested_form.git"
+ gem "nested_form"
Run
@@ -18,17 +19,18 @@ Run the generator
rails generate nested_form:install
+
== Usage
-Running the generator will add a file at public/javascripts/nested_form.js which should be included after jQuery.
+Running the generator will add a file at public/javascripts/nested_form.js which should be included after the jQuery or Prototype framework.
- <%= javascript_include_tag 'jquery', 'nested_form' %>
+ <%= javascript_include_tag :defaults, "nested_form" %>
You can then generate a nested form using the nested_form_for helper method.
<%= nested_form_for @project do |f| %>
-Use this form just like normal, including the fields_for helper method for nesting models. The benefit of this plugin comes from the link_to_add and link_to_remove helper methods on the form builder.
+Use this form just like normal, including the +fields_for+ helper method for nesting models. The benefit of this plugin comes from the +link_to_add+ and +link_to_remove+ helper methods on the form builder.
<%= f.fields_for :tasks do |task_form| %>
<%= task_form.text_field :name %>
@@ -38,6 +40,7 @@ Use this form just like normal, including the fields_for helper method for nesti
This generates links which dynamically add and remove fields.
+
== Partials
It is often desirable to move the nested fields into a partial to keep things organized. If you don't supply a block to fields_for it will look for a partial and use that.
@@ -46,7 +49,9 @@ It is often desirable to move the nested fields into a partial to keep things or
In this case it will look for a partial called "task_fields" and pass the form builder as an f variable to it.
+
== Special Thanks
-This gem is based on the plugin by Ryan Bates: http://github.com/ryanb/nested_form
+This gem was originally based on the solution by Tim Riley in his {complex-form-examples fork}[https://github.com/timriley/complex-form-examples/tree/unobtrusive-jquery-deep-fix2].
+Thank you Andrew Manshin for the Rails 3 transition, {Andrea Singh}[https://github.com/madebydna] for converting to a gem and {Peter Giacomo Lombardo}[https://github.com/pglombardo] for Prototype support.
View
@@ -1,16 +1,10 @@
-require 'bundler'
-Bundler::GemHelper.install_tasks
-
require 'rubygems'
require 'rake'
-require 'spec/rake/spectask'
-
-spec_files = Rake::FileList["spec/**/*_spec.rb"]
+require 'rspec/core/rake_task'
-desc "Run specs"
-Spec::Rake::SpecTask.new do |t|
- t.spec_files = spec_files
- t.spec_opts = ["-c"]
+desc "Run RSpec"
+RSpec::Core::RakeTask.new do |t|
+ t.verbose = false
end
task :default => :spec
View
@@ -2,5 +2,4 @@
require "nested_form/view_helper"
module NestedForm
-
-end
+end
@@ -31,4 +31,4 @@ def fields_for_nested_model(name, association, args, block)
output
end
end
-end
+end
@@ -1,3 +0,0 @@
-module NestedForm
- VERSION = "0.0.0"
-end
@@ -23,4 +23,4 @@ def after_nested_form(association, &block)
class ActionView::Base
include NestedForm::ViewHelper
-end
+end
View
@@ -1,26 +1,19 @@
-# -*- encoding: utf-8 -*-
-$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
-require 'nested_form/version'
-
Gem::Specification.new do |s|
s.name = "nested_form"
- s.version = NestedForm::VERSION
- s.platform = Gem::Platform::RUBY
+ s.version = "0.0.0"
s.authors = ["Ryan Bates", "Andrea Singh"]
- s.email = ["info@madebydna.com"]
- s.homepage = "http://github.com/madebydna/nested_form"
+ s.email = "ryan@railscasts.com"
+ s.homepage = "http://github.com/ryanb/nested_form"
s.summary = "Gem to conveniently handle multiple models in a single form."
- s.description = "Gem to conveniently handle multiple models in a single form. Rails 2 plugin by Ryan Bates converted into a gem."
+ s.description = "Gem to conveniently handle multiple models in a single form with Rails 3 and jQuery or Prototype."
+
+ s.files = Dir["{lib,spec}/**/*", "[A-Z]*"] - ["Gemfile.lock"]
+ s.require_path = "lib"
s.required_rubygems_version = ">= 1.3.6"
s.rubyforge_project = "nested_form"
- s.add_development_dependency "bundler", ">= 1.0.0.rc.5"
- s.add_development_dependency "rspec", "~> 2.0.0.beta.22"
- s.add_development_dependency "rr"
+ s.add_development_dependency "rspec", "~> 2.1.0"
+ s.add_development_dependency "rr", "~> 0.10.11" # 1.0.0 has respond_to? issues: http://github.com/btakita/rr/issues/issue/43
s.add_development_dependency "rails", "~> 3.0.0"
-
- s.files = `git ls-files`.split("\n")
- s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
- s.require_path = 'lib'
-end
+end
@@ -8,23 +8,22 @@
@template.output_buffer = ""
@builder = NestedForm::Builder.new(:item, @project, @template, {}, proc {})
end
-
+
it "should have an add link" do
@builder.link_to_add("Add", :tasks).should == '<a href="javascript:void(0)" class="add_nested_fields" data-association="tasks">Add</a>'
end
-
it "should have a remove link" do
@builder.link_to_remove("Remove").should == '<input id="item__destroy" name="item[_destroy]" type="hidden" value="false" /><a href="javascript:void(0)" class="remove_nested_fields">Remove</a>'
end
-
+
it "should wrap nested fields each in a div with class" do
2.times { @project.tasks.build }
@builder.fields_for(:tasks) do
"Task"
end.should == '<div class="fields">Task</div><div class="fields">Task</div>'
end
-
+
it "should add task fields to hidden div after form" do
output = ""
mock(@template).after_nested_form(:tasks) { |arg, block| output << block.call }
@@ -8,20 +8,20 @@
stub(@template).projects_path { "" }
stub(@template).protect_against_forgery? { false }
end
-
+
it "should pass nested form builder to form_for along with other options" do
mock.proxy(@template).form_for(:first, :as => :second, :other => :arg, :builder => NestedForm::Builder) do |form_html|
form_html
end
@template.nested_form_for(:first, :as => :second, :other => :arg) {"form"}
end
-
+
it "should pass instance of NestedForm::Builder to nested_form_for block" do
@template.nested_form_for(Project.new) do |f|
f.should be_instance_of(NestedForm::Builder)
end
end
-
+
it "should append content to end of nested form" do
@template.after_nested_form(:tasks) { @template.concat("123") }
@template.after_nested_form(:milestones) { @template.concat("456") }
View
@@ -1,3 +1,8 @@
+require 'rubygems'
+require 'bundler/setup'
+
+Bundler.require(:default)
+
require 'active_model'
require 'active_record'
require 'action_controller'

0 comments on commit 4ab1868

Please sign in to comment.