Pablo Karlsson Pablo Karlsson - 2 years ago 219
Ruby Question

Rails 5 entity path helpers method not found

After upgrading to Rails 5.0.0.beta4, I get an 'undefined method' error when trying to send an email using the Rails path helpers. I have an ActiveRecord class called

and I am trying to send an email containing a link to the projects page using the path helper `project_path( Prior to Rails 5 this used to work.

Here is the ERB for the link:

<%= project_path( %>

I'm using ActionMailer to send the email. Any ideas on what might have caused this problem after switching to Rails 5?

Answer Source

Rails 4.2 allowed this feature as a carryover from Rails versions past; however, Rails 4.2 explicitly discouraged it via documentation in the Rails 4.2 Release Notes. This documented discouragement is called deprecation, and is used as advance notice that a feature will break code in a subsequent release.

The entire purpose of deprecation is to allow the feature to continue working in the current versions, so as not to disrupt productivity. Feature-wise, this is how the architecture, libraries, and even the language move forward in a controlled manner. Note that security issues do not follow the deprecation process, and are fixed in situ in order to eliminate vulnerabilities as quickly as possible.

Rails 5 was the version that actually removed the ActionMailer support for _path helpers, which had previously been deprecated. The Rails 5.0.0.beta1 CHANGELOG shows that the break was made then. The pull request was merged in Rails 5 RC1 with this commit.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download