Hi, I am trying to override link_to in the ApplicationController as follows:
include ActionView::Helpers::UrlHelper alias_method (:link_to_original, :link_to) unless method_defined?(:link_to_original)
def link_to(name, options = {}, html_options = nil, *parameters_for_method_reference) puts "In my link_to" link_to_original(name, options, html_options, *parameters_for_method_reference) end
I get the following error:
You have a nil object when you didn't expect it! The error occured while evaluating nil.url_for
Extracted source (around line #7):
4: <div class="Logo"> 5: <%= link_to(image_tag("logo4.gif", 6: :alt => "logo", 7: :border => 0), 8: {:controller => "main", 9: :action => "index" }) 10: %>
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack1.12.1/lib/action_view/helpers/url_helper.rb:27:in `send' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack1.12.1/lib/action_view/helpers/url_helper.rb:27:in `url_for' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack1.12.1/lib/action_view/helpers/url_helper.rb:27:in `send' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack1.12.1/lib/action_view/helpers/url_helper.rb:27:in `url_for' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack1.12.1/lib/action_view/helpers/url_helper.rb:59:in `link_to' #{RAILS_ROOT}/app/views//layouts/_header.rhtml:7:in `_run_rhtml_layouts__header' #{RAILS_ROOT}/app/views/layouts/main_layout.rhtml:20:in `_run_rhtml_layouts_main_layout'
Please help.
-Vinod