Showing posts with label undefine method. Show all posts
Showing posts with label undefine method. Show all posts

Wednesday, January 4, 2012

Undefined method Object.keys


Hello Guys,
        Object.keys is depreciated and it does not support in some of the browsers like IE, FF 3.x. So we have to add the javascript object.keys method to overcome this problem.

Object.keys = function(obj) {
   if (typeof obj != "object" && typeof obj != "function" || obj == null) {
     throw TypeError("Object.keys called on non-object");
   } 
   var keys = [];
   for (var p in obj) obj.hasOwnProperty(p) && keys.push(p);
   return keys;
}

Now see we resolve the javascript error 'Undefined method Object.keys'.

Monday, November 14, 2011

Configure FCK Editor with rails 2.3.x (undefined method 'relative_url_root')

If you are trying to install fckeditor along with rails 2.3.x and get the error like
undefined method 'relative_url_root' then simply follow the below steps.

We require to add some patch for that.

Go to the fckeditor folder of plugin. and add patch for fckeditor

app/controllers/fckeditor_controller.rb

def upload_directory_path
   Replace this line (#136)
      uploaded = request
.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}"
   With
      uploaded = ActionController::Base
.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}"
    "#{uploaded}#{params[:CurrentFolder]}"
  end

lib/fckeditor.rb

Replace this line (#38)
  js_path = "#{request.relative_url_root}/javascripts"
with
  js_path = "#{ActionController::Base.relative_url_root}/javascripts"

Now restart your server. It solve the above error and fckeditor now configure successfully with your application.