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? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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... On Mar 24, 2:03 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> 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?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Mar 24, 3:29 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> 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... > > On Mar 24, 2:03 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > 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?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? On Mar 25, 3:39 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> 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. > > On Mar 24, 3:29 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > 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... > > > On Mar 24, 2:03 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > > 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?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
LeonB wrote:> 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?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 Wang --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---