Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 Project and I am trying to send an email containing a link to the projects page using the path helper `project_path(project.id). Prior to Rails 5 this used to work.

Here is the ERB for the link:

<%= project_path(@project.id) %>

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

like image 626
Pablo Jomer Avatar asked Mar 13 '23 04:03

Pablo Jomer


2 Answers

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.

like image 182
Michael Gaskill Avatar answered Mar 21 '23 08:03

Michael Gaskill


Path helpers have apparently been removed for emails in rails 5. The new syntax is as described by DickieBoy project_url which gives the whole url instead of just a part of the url.

like image 37
Pablo Jomer Avatar answered Mar 21 '23 10:03

Pablo Jomer