Sharing method and ruby ​​controller on rails 4

I have a method in the controller class

class ProjectsController < ApplicationController def download_sftp some codes here end end 

and to have access to it in my view, at the top of my controller I have this line

 helper_method :download_sftp 

when I use the following code in my view, I get the undefined download_sftp method for this project

 <tbody> <% @projects.each do |project| %> <tr> <td><%= link_to 'download',project.download_sftp(project) %></td> </tr> <% end %> </tbody> 
0
source share
1 answer

Declaring helper_method on the controller will make it available in the view just like any other helper (e.g. form_for or link_to ). However, you invoke this according to the project model. Therefore, it should be:

 <td><%= link_to 'download', download_sftp(project) %></td> 

What should download_sftp do? Perhaps he is even included in the project model.

0
source

Source: https://habr.com/ru/post/970482/


All Articles