Ruby on Rails Thursday, March 27, 2014

Thanks Vish, I also had to make an alias_method_chain in the helper's self.included

On Sunday, October 1, 2006 3:41:48 AM UTC-3, Vishnu Gopal wrote:
Overrides to link_to should go better in the ApplicationHelper. Try em there.

Vish

On 10/1/06, Vinod Krishnan < vinod....@gmail.com> wrote:

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


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0307cc89-2d19-454d-ba04-4b326e57c30b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment