Ruby on rails 从类中呈现分部时,Url帮助程序不可用
我有一个helper类,它呈现一个片段以将内容存储在数据库中 它可以正常工作,但是当视图包含url帮助器提供的url时Ruby on rails 从类中呈现分部时,Url帮助程序不可用,ruby-on-rails,Ruby On Rails,我有一个helper类,它呈现一个片段以将内容存储在数据库中 它可以正常工作,但是当视图包含url帮助器提供的url时 <%= link_to "Show project", projects_url, class: "button" %> 我在类通知中包含此帮助程序 class Notification < ActiveRecord::Base include NotificationRender ..... def self.create_for(user,
<%= link_to "Show project", projects_url, class: "button" %>
我在类通知中包含此帮助程序
class Notification < ActiveRecord::Base
include NotificationRender
.....
def self.create_for(user, event, params)
template = "notifications/_email_project"
list_params = {:template => template,:locals => params}
notification = Notification.new
notification.message = notification.render(list_params) #here I render the partial
notification.subject = I18n.t "subject.#{event}"
notification.to = user.email
notification.save
end
end
您可能必须在渲染帮助器中包含URL帮助器
class Notification < ActiveRecord::Base
include NotificationRender
.....
def self.create_for(user, event, params)
template = "notifications/_email_project"
list_params = {:template => template,:locals => params}
notification = Notification.new
notification.message = notification.render(list_params) #here I render the partial
notification.subject = I18n.t "subject.#{event}"
notification.to = user.email
notification.save
end
end