Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cells breaks asset precompilation in Rails 3.1.0.rc #51

Closed
cameel opened this issue Jun 9, 2011 · 6 comments
Closed

Cells breaks asset precompilation in Rails 3.1.0.rc #51

cameel opened this issue Jun 9, 2011 · 6 comments

Comments

@cameel
Copy link
Contributor

cameel commented Jun 9, 2011

Cells in its Railtie wants its initializers to be executed after :set_routes_preloader. I think this is a bad idea since Finisher is expected to run last. Its :finisher_hook executes :after_initialize hooks and many of them assume that initialization has already been performed. While Rails does not prevent you from doing this it was probably not expected - it causes :finisher_hook to be pushed too far down in initialization order and makes asset precompilation fail.

I think that Cells' initializers should be converted into :after_initialization hooks.

See the following links for more details:
Rails issue #1587: after_initialize hooks sometimes get executed during initialization
Rails pull request #1602: Do not TSort Finisher and Bootstrap initializers

@apotonick
Copy link
Member

Hey cameel,

the reason we chose :set_routes_preloader was to make sure routes are available for cells. Not sure if that will work if we change that to :after_initialize. Did you try it already? Would be great ;-)

@cameel
Copy link
Contributor Author

cameel commented Jun 9, 2011

Not directly, but the patch in the pull request mentioned above makes Finisher, including :set_routes_preloader, always run last and it does not break cells in my project. I am not sure how to test it more thoroughly though.

@apotonick
Copy link
Member

So how does cells' "asset breaking" look like right now? Is there an exception or something like that?

@cameel
Copy link
Contributor Author

cameel commented Jun 9, 2011

rake assets:precompile should create public/assets directory and put precompiled JavaScript and CSS there. When Cells is included in Gemfile it does not do this. There is no exception, no errors on the console, nothing. It's because Sprockets' :after_initialize runs when config.assets.paths is not yet initialized and it just thinks that there are no assets.

And it's not just rake task. The same goes if you run your Rails application - it should precompile the assets on the first access and this does not happen.

@mjtko
Copy link
Contributor

mjtko commented Jun 11, 2011

Related to this: my attempts to get cells working with rails 3.1 (and engines) initially failed until I commented out the line in the cells railtie that deals with initialization after set_routes_reloader.

I've submitted this change (removal of the specific :after option) as a pull request in #53 - my testing indicates that it makes no difference to route helper usage within cell views but does make significant difference to being able to use cells within a project that incorporates engines (and specifically engines that need their routes to be loaded after their initializers have run).

@apotonick
Copy link
Member

Hey Mark,

you're right, thanks! Not sure why I introduced the options stuff a while ago. Anyway, your fix is applied: 3455518 Thanks man!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants