[英]Helper method not exposed to controller Rails
Here's the code: 这是代码:
class SyncController < ApplicationController
def get_sync
@passed_ids = params[:ids].split(',')
@users = @passed_ids.collect{|id| User.find(id)}
#add the current user to the list
@users << current_user
@recommendations = get_recommendations(@users)
end
end
module SyncHelper
def get_recommendations(users)
users
end
end
I'm getting a can't find get_recommendations
method error... 我得到一个找不到get_recommendations
方法的错误...
Your SyncHelper
module needs to be included into your SyncController
class. 您的SyncHelper
模块需要包含在SyncController
类中。 You can either add the line 您可以添加该行
include SyncHelper
in your class definition, or, if SyncHelper
lives in the expected app/helpers file, you can use the rails helper method. 在类定义中,或者,如果SyncHelper
位于预期的app / helpers文件中,则可以使用rails helper方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.