To customize link_to


#1

Hi I’m trying to customize the link_to helper and keep getting this
error,
any suggestion how can I work arround it?

this is the error message:

undefined method link_to' for moduleUserHelper’

this is my users_helper.rb:

module UsersHelper

alias_method :link_to_original, :link_to
alias_method :link_to, :link_to_permission

def link_to_permission(name, options = {}, html_options = nil,
*parameters_for_method_reference)
if @permission
if html_options
html_options = html_options.stringify_keys
convert_options_to_javascript!(html_options)
tag_options = tag_options(html_options)
else
tag_options = nil
end
url = html_escape(options.is_a?(String) ? options :
url_for(options,
*parameters_for_method_reference))
“<a href_1234=”#{url}"#{tag_options}>#{name||url}"
else
link_to_original( name, options,
html_options,*parameters_for_method_reference )
end

end

end


#2

alias_method :link_to_original, :link_to

Isn’t it:

alias link_to_original link_to

or the other way around:

alias link_to link_to_original

but no commas, and no :interns


#3

hi, followed your suggestion, still having the same problem:

NameError in #

undefined method link_to' for moduleUsersHelper’

RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/helpers/users_helper.rb:5
#{RAILS_ROOT}/app/controllers/users_controller.rb:2
routing.rb:234:in traverse_to_controller' generated/routing/recognition.rb:3:ineval’
generated/routing/recognition.rb:3:in `recognize_path’

d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:207:in load' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:207:inload’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:39:in require_or_load' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:22:independ_on’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:178:in require_dependency' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:178:inrequire_dependency’
d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/helpe
rs.rb:70:in helper' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/helpe rs.rb:61:ineach’
d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/helpe
rs.rb:61:in helper' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/helpe rs.rb:116:ininherited_without_api’
d:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-0.9.3/lib/action_web_service
/container/action_controller_container.rb:86:in
inherited_without_action_controller' d:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-0.9.3/lib/action_web_service /dispatcher/action_controller_dispatcher.rb:34:ininherited’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:207:in load' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:207:inload’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:39:in require_or_load' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:22:independ_on’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:178:in require_dependency' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:178:inrequire_dependency’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:134:in load_file!' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:97:inconst_load!’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:80:in each' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:80:inconst_load!’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:72:in const_missing' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/routi ng.rb:234:intraverse_to_controller’
d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/routi
ng.rb:458:in recognize!' d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/dispatcher.rb:38:indispatch’
d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:117:in
handle_dispatch' d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:83:inservice’
d:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' d:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
d:/ruby/lib/ruby/1.8/webrick/server.rb:155:in start_thread' d:/ruby/lib/ruby/1.8/webrick/server.rb:144:instart’
d:/ruby/lib/ruby/1.8/webrick/server.rb:144:in start_thread' d:/ruby/lib/ruby/1.8/webrick/server.rb:94:instart’
d:/ruby/lib/ruby/1.8/webrick/server.rb:89:in each' d:/ruby/lib/ruby/1.8/webrick/server.rb:89:instart’
d:/ruby/lib/ruby/1.8/webrick/server.rb:79:in start' d:/ruby/lib/ruby/1.8/webrick/server.rb:79:instart’
d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:69:in
dispatch' d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/commands/servers/webrick.rb: 59 d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire__’
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
require' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:214:inrequire’
d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/commands/server.rb:28
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
require__' d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:214:in `require’
script/server:3

#{RAILS_ROOT}/app/helpers/users_helper.rb:5
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:207:in load' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:207:inload’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:39:in require_or_load' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:22:independ_on’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:178:in require_dependency' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:178:inrequire_dependency’
d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/helpe
rs.rb:70:in helper' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/helpe rs.rb:61:ineach’
d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/helpe
rs.rb:61:in helper' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/helpe rs.rb:116:ininherited_without_api’
d:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-0.9.3/lib/action_web_service
/container/action_controller_container.rb:86:in
inherited_without_action_controller' d:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-0.9.3/lib/action_web_service /dispatcher/action_controller_dispatcher.rb:34:ininherited’
#{RAILS_ROOT}/app/controllers/users_controller.rb:2
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:207:in load' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:207:inload’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:39:in require_or_load' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:22:independ_on’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:178:in require_dependency' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:178:inrequire_dependency’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:134:in load_file!' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:97:inconst_load!’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:80:in each' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:80:inconst_load!’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:72:in const_missing' routing.rb:234:intraverse_to_controller’
generated/routing/recognition.rb:3:in eval' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/routi ng.rb:234:intraverse_to_controller’
generated/routing/recognition.rb:3:in recognize_path' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/routi ng.rb:458:inrecognize!’
d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/dispatcher.rb:38:in
dispatch' d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:117:inhandle_dispatch’
d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:83:in
service' d:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
d:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run' d:/ruby/lib/ruby/1.8/webrick/server.rb:155:instart_thread’
d:/ruby/lib/ruby/1.8/webrick/server.rb:144:in start' d:/ruby/lib/ruby/1.8/webrick/server.rb:144:instart_thread’
d:/ruby/lib/ruby/1.8/webrick/server.rb:94:in start' d:/ruby/lib/ruby/1.8/webrick/server.rb:89:ineach’
d:/ruby/lib/ruby/1.8/webrick/server.rb:89:in start' d:/ruby/lib/ruby/1.8/webrick/server.rb:79:instart’
d:/ruby/lib/ruby/1.8/webrick/server.rb:79:in start' d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:69:indispatch’
d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/commands/servers/webrick.rb:
59
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
require__' d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire’
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend
encies.rb:214:in require' d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/commands/server.rb:28 d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire__’
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
require' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/depend encies.rb:214:inrequire’
script/server:3

This error occured while loading the following files:
./script/…/config/…/app/controllers/users_controller.rb
users_helper.rb