Less Undefined Method Error

less undefined method error

From the fine manual:

darken

Decrease the lightness of a color by an absolute amount.

Parameters:

  • color: A color object.
  • amount: A percentage 0-100%.

Returns: color

The darken function wants a color but your @navbarBackground is a URL for a background image. You're getting a complaint about toHSL because LESS is trying to convert the color to the HSL format to make the darkening computation easier.

I don't know of any way to darken an image through LESS, you might need to manually darken the image and switch between them as needed.

Rails railties gem error undefined method: 'less'

The twitter bootstrap gem depends on the less gem. From the docs:

gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"

I've personally found it easier for twitter bootstrap to just dump the files from the official site into the vendor/assets directory. Updating from the gem is marginally easier than by hand, but when updating bootstrap, you kind of want to do it "by hand" and check it all out "by eye" anyway - I prefer the extra effort, to ensure it does not get done lightly. Also, it is very hard to remove certain (for example) responsive portions from the gem, without (as far as I could tell) "unspecifying" the styles. The responsive stuff changes, from version to version, in terms of size, so you can't just rely on it all working. I really can't see any advantage to using the gem.

Update

There is now an official gem for this, which I recommend checking out: https://github.com/twbs/bootstrap-sass

undefined method `new' for #Grease::Adapter(Less::Rails::ImportProcessor)

The issue was resolved and it was due to the "grease" gem dependency for updated "less-rails" gem (v3.0.0).

"Grease" dependency was created when I updated an existing gem version in my Gemfile which updated the "less-rails" gem version from "2.8.0" to "3.0.0" in Gemfile.lock as well.

Then I set the "less-rails" version to the old one (previously being used in Gemfile.lock):

gem "less-rails", "~> 2.8.0"

Grease gem dependency is required only for "less-rails" 3.0.0 version and above so lower version did not create this dependency which resolved the issue.

Official page for less-rails(3.0.0) dependencies: https://rubygems.org/gems/less-rails/versions/3.0.0

undefined method `empty?' for nil:NilClass in application.less

I suspect you have gem version inconsistencies... you should compare your Gemfile.lock against your colleagues' Gemfile.lock.

If you've done a bundle update that's a likely cause of the problem. It's a useful tool but needs to be run with "extreme caution".

http://ryanbigg.com/2011/01/why-you-should-run-bundle-update/

Cheers
Steve

LESS compiler says parameter is undefined

Quoting Less Website

If the compiler sees at least one semicolon inside mixin call or declaration, it assumes that arguments are separated by semicolons and all commas belong to CSS lists.

The above implies that when you call the mixin in the below format, the mixin call has only 2 values (or parameters). First parameter has the value of @slide variable and the second is the entire remaining part (which is "../images/ghp.png", 12%).

.slide(@slide; "../images/ghp.png", 12%);

This is the reason why you get the error saying one of the variables is undefined. This can be overcome by using the same separator (either semi-colon or coma, the preference being semi-colon).

So, for example the below code would compile perfectly fine.

.slide(parallax; @bg; @padding) {
background: url(@bg) 50% 0 fixed;
height: auto;
margin: 0 auto;
width: 100%;
position: relative;
}

.slide(np; @bg; @padding) {
background-color: @bg;
}

.slide(@_; @bg; @padding) {
padding: @padding 0;
}

@slide: parallax;
#ghp {
.slide(@slide; "../images/ghp.png"; 12%);
}

Undefined Method error in Ruby class

You have a typo in the word initalize. It should be initialize.

And because of the typo, the initalize method is not called when the object is created, and hence the instance variable @height is not defined on creation. And you cannot call += on an object that does not exist yet.

Also as a side note, you shouldn't be adding too many blank lines out of the blue. This is against the Ruby Style Guide.

undefined method `reduce'

Check you deployment ruby version. reduce wasn't added to Enumerable until 1.8.7. You can also try using inject. It's the same as reduce, just with a less obvious name.

Ruby undefined method error

Alright so the problem was a wrong SQL query which was returning wrong values, therefore some of them didn't had .id method in them. Corrected the SQl query and tried to access the id by ActiveRecord::Relation["id"] solved the problem.

Thank you for everyone that tried to help!



Related Topics



Leave a reply



Submit