ryanb/nifty-generators

namespacing model attributes

drhenner opened this issue · 0 comments

When I create a namespace using nifty:scaffold without arguments, the only attribute is :name (even if "name" isn't an attribute)

I'd make a pull request for this but I have forked nifty-generators, quite a bit and I don't really know if it's possible to have 2 forks of the same repo. Either way the fix is pretty easy.

go into lib/generators/nifty/scaffold/scaffold_generator.rb (line 296)

Change to this:

  def model_exists?
         File.exist?( destination_path("app/models/#{singular_name}.rb")) || File.exist?( destination_path("app/models/#{instance_name}.rb"))
  end

I think people rarely namespace the models so you might not need:

File.exist?( destination_path("app/models/#{singular_name}.rb"))