Rails Cannot call charAt method from undefined

I have a Rails application that received the following error:

Less::ParseError in Home#index Showing /Users/burtondav/sites/requestsys/app/views/layouts/application.html.erb where line #20 raised: Cannot call method 'charAt' of undefined (in /Users/burtondav/sites/requestsys/app/assets/stylesheets/bootstrap_and_overrides.css.less) Extracted source (around line #20): 17: } 18: </style> 19: 20: <%= stylesheet_link_tag "application", :media => "all" %> 

Some of the GEMS that I use:

 gem 'rails', '3.2.11' gem 'twitter-bootstrap-rails' group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'less-rails' gem 'commonjs' gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end 

There seems to be a problem with LESS that Bootstrap is using.

I read a few other similar questions. So, I upgraded Ruby to 1.9.3p374. But that did not fix the problem.

Any ideas?

THANKS!

UPDATE

This is bootstrap_and_overrides.css.less

 @import "twitter/bootstrap/bootstrap"; @import "twitter/bootstrap/responsive"; // Set the correct sprite paths @iconSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings"); @iconWhiteSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings-white"); 
+8
ruby-on-rails twitter-bootstrap
source share
4 answers

Followed you in the comments. It seems that the answer is to open the github problem with twitter-bootstrap-rails or less rails describing your problem. You can also run the initial release: https://github.com/seyhunak/twitter-bootstrap-rails/issues/72

Otherwise, you are offered two solutions:

+1
source share

I have a temporary problem. There is a syntax change for mixins.less, which is apparently only supported by LESS.js

As an example:

Release after 2.3:

 .offsetX (@index) when (@index > 0) { .offset@{index} { .offset(@index); } .offset@{index}:first-child { .offsetFirstChild(@index); } .offsetX(@index - 1); } 

Pre-2.3 Release

 .offsetX (@index) when (@index > 0) { (~'.offset@{index}') { .offset(@index); } (~'.offset@{index}:first-child') { .offsetFirstChild(@index); } .offsetX(@index - 1); } 

After adding (~ "") back in all places it was deleted (you will need to look at diff from version 2.3 and release before it is deleted, all my assets will compile again without errors and still use LESS.

This change was only in mixins.less btw and only about 5 or 6 lines.

+4
source share

The same failure turned out. Fixed it by dropping twitter-bootstrap-rails to version 2.1.4 (at the time of writing the latter was 2.2.4 )

 # Gemfile ... group :assets do ... gem "therubyracer" gem "less-rails" end gem "twitter-bootstrap-rails", '2.1.4' 
+3
source share

I solved it in a roundabout way, so YMMV. In my case, this error was caused by updating twitter-bootstrap-rails from 2.1.6 to 2.2.5 without any changes in any files. Therefore, trying to reproduce this during the development process, I noticed 404s for requests for half-icon icons:

 ActionController::RoutingError (No route matches [GET] "/assets/twitter/bootstrap/glyphicons-halflings"): 

Since I use font-awesome, I just removed all references to these sprites from my CSS:

 # bootstrap_and_override.less //@iconSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings"); //@iconWhiteSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings-white"); // Glyphicons //@import "twitter/bootstrap/sprites.less"; 

This, in turn, led to this error:

 variable @fontAwesomeEotPath_iefix is undefined 

which is a common update problem here too by adding this line:

 @fontAwesomeEotPath_iefix: asset-path("fontawesome-webfont.eot#iefix"); 

After that, everything works again.

0
source share

All Articles