module Godmode::Generators::OrmHelpers
Public Instance Methods
needs_attr_accessible?()
click to toggle source
# File lib/generators/godmode/orm_helpers.rb, line 4 def needs_attr_accessible? rails_3? && !strong_parameters_enabled? end
rails_3?()
click to toggle source
# File lib/generators/godmode/orm_helpers.rb, line 8 def rails_3? Rails::VERSION::MAJOR == 3 end
strong_parameters_enabled?()
click to toggle source
# File lib/generators/godmode/orm_helpers.rb, line 12 def strong_parameters_enabled? defined?(ActionController::StrongParameters) end
Private Instance Methods
migration(src, dest)
click to toggle source
# File lib/generators/godmode/orm_helpers.rb, line 18 def migration src, dest unless migration_exists? dest migration_template src, "db/migrate/gdd_#{dest}.rb" rake "db:migrate" end end
migration_exists?(name)
click to toggle source
# File lib/generators/godmode/orm_helpers.rb, line 29 def migration_exists?(name) Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_gdd_#{name}.rb$/).first end
migration_path()
click to toggle source
# File lib/generators/godmode/orm_helpers.rb, line 33 def migration_path @migration_path ||= File.join("db", "migrate") end
model_exists?()
click to toggle source
# File lib/generators/godmode/orm_helpers.rb, line 25 def model_exists? File.exists?(File.join(destination_root, model_path)) end
model_path()
click to toggle source
# File lib/generators/godmode/orm_helpers.rb, line 37 def model_path @model_path ||= File.join("app", "models", "#{file_path}.rb") end