Skip to content

Commit

Permalink
added support for simple_form
Browse files Browse the repository at this point in the history
  • Loading branch information
fxposter committed May 15, 2011
1 parent e9afa7b commit e083c26
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,5 @@
*.gem
Gemfile.lock
.bundle
Gemfile
log
1 change: 0 additions & 1 deletion Gemfile → Gemfile-base
@@ -1,3 +1,2 @@
source "http://rubygems.org"

gemspec
3 changes: 3 additions & 0 deletions Gemfile-simple_form
@@ -0,0 +1,3 @@
source "http://rubygems.org"
gemspec
gem 'simple_form'
19 changes: 18 additions & 1 deletion Rakefile
Expand Up @@ -2,9 +2,26 @@ require 'rubygems'
require 'rake'
require 'rspec/core/rake_task'

task :spec do
`rm Gemfile` if File.exists?('./Gemfile')
`cp Gemfile-base Gemfile`
`bundle install`
end

task :simple_form_spec do
`rm Gemfile` if File.exists?('./Gemfile')
`cp Gemfile-simple_form Gemfile`
`bundle install`
end

desc "Run RSpec"
RSpec::Core::RakeTask.new do |t|
t.verbose = false
end

task :default => :spec
desc "Run RSpec for SimpleForm Gemfile"
RSpec::Core::RakeTask.new(:simple_form_spec) do |t|
t.verbose = false
end

task :default => [:spec, :simple_form_spec]
11 changes: 10 additions & 1 deletion lib/nested_form/builder.rb
@@ -1,5 +1,14 @@
module NestedForm
class Builder < ::ActionView::Helpers::FormBuilder
def self.base_builder_class
begin
require 'simple_form'
::SimpleForm::FormBuilder
rescue LoadError
::ActionView::Helpers::FormBuilder
end
end

class Builder < base_builder_class
# Adds a link to insert a new associated records. The first argument is the name of the link, the second is the name of the association.
#
# f.link_to_add("Add Task", :tasks)
Expand Down

0 comments on commit e083c26

Please sign in to comment.