Extend url_for

Hi!

I want to extend the url_for function (and some more functions) with a
plugin.

Now I tried this:

ExtendBase

module ActiveController
class Base

def url_for
  'OK'
end

end
end

def url_for
‘OK’
end

But that didn’t have any effect. I have this in my init.rb:

Include hook code here

require ‘extend_base’

Anyone knows what could be wrong?

Tried this also:

module ActionView
module Helpers
module UrlHelper
alias_method :force_link_to, :link_to

  def link_to(name, options = {}, html_options = nil,

*parameters_for_method_reference)
‘OK’
end

end

end
end

But nothing! Not even an error message…

OK. The problem was that I mixed (well I believe that was the problem)
unix and windows characters. When I threw the file away and typed it
from scratch the problem was solved.

Another problem arises. I have this in my plugin lib:

module ActionController
module Routing
def get_default_controller

ActionController::Routing::Routes.routes[0].requirements[:controller]
end
def get_default_action
ActionController::Routing::Routes.routes[0].requirements[:action]
end
end
end

But when I do this in a view: <%= debug
ActionController::Routing.get_default_controller %>

I get this error: undefined method `get_default_controller’ for
ActionController::Routing:Module

Does anyone know what could be the problem here?

LeonB wrote:

end

end
end

But when I do this in a view: <%= debug
ActionController::Routing.get_default_controller %>

I get this error: undefined method `get_default_controller’ for
ActionController::Routing:Module

Does anyone know what could be the problem here?

Try it with a “self.” in front of the method name as in:

def self.get_default_controller

end

def self.get_default_action

end


Michael W.