Skip to content

Commit

Permalink
added simple form dependency; fixed/added option for simple_form in s…
Browse files Browse the repository at this point in the history
…caffold_generator and nifty_scaffold_generator; added simple_form? method
  • Loading branch information
greenplastik committed Dec 4, 2010
1 parent 82e32f6 commit 8eadafe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/generators/nifty/scaffold/scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ScaffoldGenerator < Base
class_option :testunit, :desc => 'Use test/unit for test files.', :group => 'Test framework', :type => :boolean
class_option :rspec, :desc => 'Use RSpec for test files.', :group => 'Test framework', :type => :boolean
class_option :shoulda, :desc => 'Use shoulda for test files.', :group => 'Test framework', :type => :boolean
class_option :simple_form, :desc => "Use simple_form in views", :type => :boolean
class_option :simple_form, :desc => 'Use simple_form for forms in views.', :type => :boolean

def initialize(*args, &block)
super
Expand Down
1 change: 1 addition & 0 deletions nifty-generators.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'mocha', '~> 0.9.8'
s.add_development_dependency 'bcrypt-ruby', '~> 2.1.2'
s.add_development_dependency 'sqlite3-ruby', '~> 1.3.1'
s.add_development_dependency 'simple_form'

s.rubyforge_project = s.name
s.required_rubygems_version = ">= 1.3.4"
Expand Down
7 changes: 6 additions & 1 deletion rails_generators/nifty_scaffold/nifty_scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def manifest
end

if form_partial?
if options[:simple_form]
if simple_form?
m.template "views/#{view_language}/_simple_form.html.#{view_language}", "app/views/#{plural_name}/_form.html.#{view_language}"
else
m.template "views/#{view_language}/_form.html.#{view_language}", "app/views/#{plural_name}/_form.html.#{view_language}"
Expand Down Expand Up @@ -188,6 +188,10 @@ def model_columns_for_attributes
def rspec?
test_framework == :rspec
end

def simple_form?
options[:simple_form]
end

protected

Expand Down Expand Up @@ -215,6 +219,7 @@ def add_options!(opt)
opt.on("--testunit", "Use test/unit for test files.") { options[:test_framework] = :testunit }
opt.on("--rspec", "Use RSpec for test files.") { options[:test_framework] = :rspec }
opt.on("--shoulda", "Use Shoulda for test files.") { options[:test_framework] = :shoulda }
opt.on("--simple_form", "Use simple_form for forms in views.") { |v| options[:simple_form] = v }
end

# is there a better way to do this? Perhaps with const_defined?
Expand Down

0 comments on commit 8eadafe

Please sign in to comment.