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.

No comments:

Post a Comment