scriptonia

Oct 19 '11

How to test rails helpers in console

# How to test application helpers via terminal.
# For example you are using devise.
# Type in terminal the next following lines.

class << self
  def current_user
    User.find_by_name("your username")
  end
end

include ApplicationHelper

# if you want to see how your helper is rendering
# content_tag you need to make include module

include ActionView::Helpers::TagHelper

# And now run helper.

your_helper_method_that_will_render_link

"<li><a class=\"c1\" href=\"/\">Home</a></li>"

# That's it

view raw test.rb This Gist brought to you by GitHub.

View comments

Blog comments powered by Disqus