How to use Rails URL helpers in any Ruby class
In Rails 3+, you can use:
class Project delegate :url_helpers, to: 'Rails.application.routes' def project_path url_helpers.project_path(self) end end
For Rails 2, use the attached
#url_writer, on which you can call URL helpers:
class Foo does 'write_urls' def self.class_method url_writer.session_path end def instance_method url_writer.project_path(5) end end
Flaky tests are tests that sometimes fail for no obvious reason. They are the plague of many end-to-end (E2E) test suites that automate the browser through tools like Capybara and Selenium.
Join our free training event and learn to fix any flaky test suite, even in large legacy applications.