trailblazer / cells

View components for Ruby and Rails.
https://trailblazer.to/2.1/docs/cells.html
3.07k stars 236 forks source link

Constant loading issue? #299

Closed marcelloma closed 8 years ago

marcelloma commented 9 years ago

Hi,

I have a model called Partner which isn't inside any module and when I try to create a cell called Administration::PartnerCell rails seems to be generating a module named after my model when I use this particular cell name. Any different name works fine but this one makes usage of my model class fail because it looks up the method calls on a module instead of calling on the actual model. I don't have any module called Partner. I'm assuming that because the name of the cell is PartnerCell and the view directory is partner rails might be namespacing this directory and creating a module so that classes inside that directory could use:

class ModuleName::ClassName
end
# instead of

module ModuleName
  class ClassName
  end
end

i.e.: undefined method `page' for Administration::Partner:Module

Is this a common issue? I believe I've seen this issue before outside cells, with just rails, but I'm not sure. Is there a solution outside using other names?

Thanks in advance!

apotonick commented 9 years ago

As discussed on IRC:

  1. You have a model ::Partner.
  2. Administration::PartnersController.
  3. You have a directory app/cells/administration/partner.

This is enough to crash the Rails autoloader?

marcelloma commented 9 years ago

Heres a sample app reproducing the issue https://github.com/marcelloma/helloworld