zweilove / css_splitter

Gem for splitting up stylesheets that go beyond the IE limit of 4095 selectors, for Rails 3.1+ apps using the Asset Pipeline.
MIT License
160 stars 47 forks source link

undefined method `split_stylesheet_link_tag' for #<#<Class:0x007fdaa1692700>:0x007fda9f2c0d40> #11

Closed bkahl closed 11 years ago

bkahl commented 11 years ago

I'm having an issue with trying to precompile assets for staging environment.

I'm running:

ruby 1.9.3p327 rails 3.2.13.rc2

and I've followed your steps by adding the following: 1) the css splitter gem to my GEMFILE. 2) updating the application.rb config.assets.precompile to add my newly added application_split2.css file. note i didn't add the config.assets.compress = true to the applications.rb file b/c RubyMine gave me a message saying 'cannot find compress' 3) i created a new application_split2.css.scss.split2 file within the assets pipeline and made it reference the application.css.scss file by importing it like so:


Steps followed after updating the files: 1) bundle install 2) RAILS_ENV=staging rake assets:precompile 3) restarted rails server

THEN got the following error when going to http://localhost:3000

NoMethodError in Home#index

What am I missing?

Your help is greatly appreciated!

jhilden commented 11 years ago

Hey Brad,

I don't really know why the split_stylesheet_link_tag helper for some reason isn't loaded/available in your app. It is defined here: https://github.com/zweilove/css_splitter/blob/master/app/helpers/css_splitter/application_helper.rb and loaded here: https://github.com/zweilove/css_splitter/blob/master/lib/css_splitter/engine.rb#L9-L13 I have to dig a little deeper to figure out what could be wrong here.

As a workaround/quickfix I would recommend you simply do the include yourself, manually writing the code that the helper would produce. Something like this:

= stylesheet_link_tag "application", :media => "all"
/[if IE lte IE 9]
  = stylesheet_link_tag "application_split2", :media => "all"

Let me know if that works for you in the meantime and I will get back to you once I know more about why the helper could not be loaded.

bkahl commented 11 years ago

thanks, i already tried that.

i think the current project im working on now is more then that because i found a counter to count my selectors and its less then 4095 so the css_splitter shouldn't even be a factor, im thinking the css isn't loading in ie9 properly due to either the bootstrap sass gem overwriting some of the predefined styles.

we ended up getting control of a project from our outsourced team and they totally botched this project up so im trying to run through the entire pipeline.

i even tried bless just as a second potential option but neither have worked which is why i think it has something to do with the bootstrap gem itself, your really supposed to predefine some of your default elements before the bootstrap gem to prevent the bootstrap from overwriting some of your styles but that isn't what the previous owners of this project did.

ehhh.... this has been kind of frustrating and ive been dealing with it for the last 2 days.

but i don't think it has anything to do with your gem.

thanks for your help.

have a good weekend.

brad

On Fri, Mar 15, 2013 at 5:28 PM, Jakob Hilden notifications@github.comwrote:

Hey Brad,

I don't really know why the split_stylesheet_link_tag helper for some reason isn't loaded/available in your app. It is defined here: https://github.com/zweilove/css_splitter/blob/master/app/helpers/css_splitter/application_helper.rband loaded here: https://github.com/zweilove/css_splitter/blob/master/lib/css_splitter/engine.rb#L9-L13I have to dig a little deeper to figure out what could be wrong here.

As a workaround/quickfix I would recommend you simply do the include yourself, manually writing the code that the helper would produce. Something like this:

= stylesheet_link_tag "application", :media => "all" /[if IE lte IE 9] = stylesheet_link_tag "application_split2", :media => "all"

Let me know if that works for you in the meantime and I will get back to you once I know more about why the helper could not be loaded.

— Reply to this email directly or view it on GitHubhttps://github.com/zweilove/css_splitter/issues/11#issuecomment-14985903 .

Thanks,

Brad Kahl Software Developer M 540.314.8352

linjunpop commented 11 years ago

@bkahl Did you put this gem in the assets group in your Gemfile? If I do that, I get the same problem.

It works for me to move this gem out of assets group.

jhilden commented 11 years ago

@linjunpop That's a very good point. I added a little note to the README. Do you think that will make things more clear? https://github.com/zweilove/css_splitter/commit/ecde6b0445f07dbd39f0c28dcca74dda00126028

@bkahl Please let us know if that fixed your problem.

jhilden commented 11 years ago

@bkahl any feedback? Can this issue be closed?

bkahl commented 11 years ago

hey @jhilden, sorry for the late response and not closing this out, but yes, this issue is solved, therefore, I'm closing it out. thanks for your help!

bowd commented 10 years ago

@bkahl can you confirm that the issue cam from having the gem in the assets group? I've suddenly hit this (after 3 weeks of having it in production, working) on a branch where I've added active-admin. I'm still investigating but It would be nice to know if your problem was different as well and how you fixed it. Thanks.

jhilden commented 10 years ago

Don't really know what the issue could be here, but from personal experience I would recommend rails_admin over active_admin. Maybe that won't give you any issues.

muskosan commented 9 years ago

I'm running into this same issue, with the gem outside the assets group

jhilden commented 9 years ago

@muskosan can you provide some more details on used versions (gem, rails, ruby, ...), error messages, etc.?

muskosan commented 9 years ago

Sure,

Error: undefined method `split_stylesheet_link_tag' for #<#Class:0x007fe20d023a40:0x007fe2069c42b8>

gem v .0.4.0. Rails 3.2.19 ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]

Using the helper isn't a necessity, though it would be nice.

jhilden commented 9 years ago

hmm. seems like this part is not working for you: https://github.com/zweilove/css_splitter/blob/master/lib/css_splitter/engine.rb#L9-L13 (maybe it's not working for rails3)

you can always include the helper manually in your ApplicationController

kaliara commented 9 years ago

I found that when using Pow as my local Rack server, I had to restart it to get this error to go away.

jefigo commented 8 years ago

I had the same issue running on ruby 2.2.2p95 and Rails 4.2.3 application. I had to include helper CssSplitter::ApplicationHelper in the ApplicationController and that worked for me.

constantm commented 8 years ago

Thanks @jefigo, thank did the trick! For me this is caused by using the ember-cli-rails gem. When I remove the gem, it works fine.