I need the function auto_link in my project.
So I try to install the gem rails_autolink.
In the Gemfile:
gem 'rails_autolink'
Then I stop the server, run bundle install
, start the server.
In my controller:
require 'rails_autolink'
# ...
auto_link("Go to http://www.rubyonrails.org and say hello to david@loudthinking.com")
And I get:
NoMethodError in Relation::CustomsController#index
undefined method `auto_link' for
In app/controllers/relation/customs_controller.rb:12:in `index'
How do I include rails_autolink properly ?
Edit: gem install rails_autolink
doesn't help.
My guess would be that auto_link
is not working because you're calling it in the context of the controller. Try doing
class CustomsController < ApplicationController
include ActionView::Helpers::TextHelper
end
(If you look at the source code here, you'll see that auto_link
is part of something called TextHelper
.)
Or, if possible, move the auto_link
call from the controller to the view. It's view-related logic, anyway.