简体   繁体   English

ActionView :: Template :: Error(未定义的局部变量或方法`check_public'

[英]ActionView::Template::Error (undefined local variable or method `check_public'

I am working on an issue on diaspora* related to email notifications: 我正在处理与电子邮件通知相关的diaspora *问题:

Private post: show a link (no text) in the email notification 私人讯息:在电子邮件通知中显示链接(无文字)

Public post: show a summary and a link in the email notification 公开帖子:在电子邮件通知中显示摘要和链接

Here is my Pull Request to diaspora*: https://github.com/diaspora/diaspora/pull/4508 这是我对散居国外*的拉取请求: https : //github.com/diaspora/diaspora/pull/4508

Link to my Github Repo: https://github.com/railsgirls-generator-app/diaspora/tree/4266-remove-content-from-email-notifications 链接到我的Github存储库: https : //github.com/railsgirls-generator-app/diaspora/tree/4266-remove-content-from-email-notifications

This line gives an error: 行给出了一个错误:

ActionView::Template::Error (undefined local variable or method `check_public' for #<#<Class:0xd1e5638>:0xb5081bf4>):
1: <% ispublic = check_public(@notification.post) %>
2: <% if ispublic == true %>
3: <%= comment_message(@notification.comment, :process_newlines => true) %>
4: 
  app/views/notifier/comment_on_post.markerb:1:in `_app_views_notifier_comment_on_post_markerb__51526760__628881328'

How can I resolve this issue? 我该如何解决这个问题?

i am just guessing, as i would have to know the codebase better to really understand the issue. 我只是在猜测,因为我必须更好地了解代码库才能真正理解该问题。

what i can see from a glance: 我一眼就能看到:

  1. you are calling check_public in a mailer template 您正在邮件模板中调用check_public
  2. check_public is defined in app/helpers/notifier_helper.rb check_publicapp/helpers/notifier_helper.rb定义
  3. an error is raised because the method is not exposed for rendering 由于未公开要渲染的方法而引发错误

so i guess that including NotifierHelper in CommentOnPost would fix the problem. 所以我想在CommentOnPost中包含NotifierHelper可以解决问题。

ActionView::Template::Error (#&lt;# 的未定义局部变量或方法“事件” <class::0x000.. rails 6 ajax< div><div id="text_translate"><p> 我建立了一个表格,允许您内联编辑记录; 我遇到的问题是部分数据在视图中刷新后不会重新渲染数据。 我正在使用单独的 controller 来处理更新/编辑部分渲染。 我可以成功地内联呈现表单,我只是无法通过更新部分错误而没有收到未定义的局部变量。 如何在不同的 controller 中重新渲染我的 update.js.erb 操作的部分?</p><p> <strong>图表/facility_chart.html.erb</strong></p><pre> &lt;div class="divTable greyGridTable"&gt; &lt;div class="divTableHeading"&gt; &lt;div class="divTableRow"&gt; &lt;div class="divTableHead"&gt;Date&lt;/div&gt; &lt;% @facility_chart_events.select(:name).distinct.each |event_name| %&gt; &lt;div class="divTableHead"&gt;&lt;%= event_name %&gt;&lt;/div&gt; &lt;% end %&gt; &lt;div class="divTableHead"&gt;Update/Change&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="divTableBody"&gt; &lt;% @facility_event_grids.each do |event| %&gt; &lt;%= content_tag:div, class: 'divTableRow', id: dom_id(event) do %&gt; &lt;%= render partial: "facility_event_trackers/facility_event_tracker", :locals =&gt; {event: event} %&gt; &lt;% end %&gt; &lt;% end %&gt; &lt;/div&gt; &lt;/div&gt;</pre><p> <strong>_inline_form.html.erb</strong></p><pre> &lt;%= form_with model: facility_event_tracker, class: 'divTableRow', id: dom_id(facility_event_tracker, 'inline_form'), local: false do |f| %&gt; &lt;div class="divTableCell"&gt; &lt;%= chart_tracker_grid_date(f.object.start_time) %&gt; &lt;/div&gt; &lt;div class="divTableCell"&gt; &lt;%= text_field:event_count, label: false %&gt; &lt;/div&gt; &lt;% end %&gt; &lt;div class="divTableCell"&gt; &lt;%= f.submit 'Submit', class: 'ui black button basic' %&gt; &lt;/div&gt;</pre><p> <strong>图表控制器.rb</strong></p><pre> def facility_chart @facility = Facility.find(params[:id]) @facility_events_grids = @facility.facility_event_trackers.order(start_time: :desc).page(params[:page]).per(40) end</pre><p> <strong>facility_event_trackers_controller.rb</strong></p><pre> def edit end def update respond_to do |format| if @facility_event_tracker.update(facility_event_tracker_params) format.js {} else format.js {} end</pre><p> <strong>编辑.js.erb</strong></p><pre> document.getElementById('&lt;%= dom_id(@facility_event_tracker) %&gt;').insertAdjacentHTML('afterend', "&lt;%= j render 'inline_form', facility_event_tracker: @facility_event_tracker %&gt;");</pre><p> <strong>更新.js.erb</strong></p><pre> document.getElementById('&lt;%= dom_id(@facility_event_tracker, 'inline_form') %&gt;').remove() document.getElementById('&lt;%= dom_id(@facility_event_tracker, 'inline_form') %&gt;').innerHTML = &lt;%= j render "facility_event_trackers/facility_event_tracker", facility_event_tracker: @facility_event_tracker %&gt;" document.getElementById('&lt;%= dom_id(@facility_event_tracker) %&gt;').style.display = 'table-row'</pre><p> <strong>Rails 控制台错误</strong></p><p> // 部分无法重新渲染以进行更新</p><pre>ActionView::Tempalate::Error (undefined local variable or method `event' for #&lt;#&lt;Class:0x00000&gt;:0x00005&gt;): 1: &lt;div class="divTableCell"&gt;&lt;%= chart_tracker_grid_date(event.start_time) %&gt;... 2: &lt;div class="divTableCell"&gt;&lt;%= event.event_count %&gt;&lt;/div&gt; app/views/facility_event_trackers/_facility_event_tracker.html.erb:1 app/views/facility_event_trackers/update.js.erb</pre></div></class::0x000..> - ActionView::Template::Error (undefined local variable or method `event' for #<#<Class::0x000.. Rails 6 AJAX

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ActionView :: Template :: Error(未定义的局部变量或方法“ new _ * _ path”) - ActionView::Template::Error (undefined local variable or method `new_*_path') ActionView::Template::Error (#&lt;# 的未定义局部变量或方法“事件” <class::0x000.. rails 6 ajax< div><div id="text_translate"><p> 我建立了一个表格,允许您内联编辑记录; 我遇到的问题是部分数据在视图中刷新后不会重新渲染数据。 我正在使用单独的 controller 来处理更新/编辑部分渲染。 我可以成功地内联呈现表单,我只是无法通过更新部分错误而没有收到未定义的局部变量。 如何在不同的 controller 中重新渲染我的 update.js.erb 操作的部分?</p><p> <strong>图表/facility_chart.html.erb</strong></p><pre> &lt;div class="divTable greyGridTable"&gt; &lt;div class="divTableHeading"&gt; &lt;div class="divTableRow"&gt; &lt;div class="divTableHead"&gt;Date&lt;/div&gt; &lt;% @facility_chart_events.select(:name).distinct.each |event_name| %&gt; &lt;div class="divTableHead"&gt;&lt;%= event_name %&gt;&lt;/div&gt; &lt;% end %&gt; &lt;div class="divTableHead"&gt;Update/Change&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="divTableBody"&gt; &lt;% @facility_event_grids.each do |event| %&gt; &lt;%= content_tag:div, class: 'divTableRow', id: dom_id(event) do %&gt; &lt;%= render partial: "facility_event_trackers/facility_event_tracker", :locals =&gt; {event: event} %&gt; &lt;% end %&gt; &lt;% end %&gt; &lt;/div&gt; &lt;/div&gt;</pre><p> <strong>_inline_form.html.erb</strong></p><pre> &lt;%= form_with model: facility_event_tracker, class: 'divTableRow', id: dom_id(facility_event_tracker, 'inline_form'), local: false do |f| %&gt; &lt;div class="divTableCell"&gt; &lt;%= chart_tracker_grid_date(f.object.start_time) %&gt; &lt;/div&gt; &lt;div class="divTableCell"&gt; &lt;%= text_field:event_count, label: false %&gt; &lt;/div&gt; &lt;% end %&gt; &lt;div class="divTableCell"&gt; &lt;%= f.submit 'Submit', class: 'ui black button basic' %&gt; &lt;/div&gt;</pre><p> <strong>图表控制器.rb</strong></p><pre> def facility_chart @facility = Facility.find(params[:id]) @facility_events_grids = @facility.facility_event_trackers.order(start_time: :desc).page(params[:page]).per(40) end</pre><p> <strong>facility_event_trackers_controller.rb</strong></p><pre> def edit end def update respond_to do |format| if @facility_event_tracker.update(facility_event_tracker_params) format.js {} else format.js {} end</pre><p> <strong>编辑.js.erb</strong></p><pre> document.getElementById('&lt;%= dom_id(@facility_event_tracker) %&gt;').insertAdjacentHTML('afterend', "&lt;%= j render 'inline_form', facility_event_tracker: @facility_event_tracker %&gt;");</pre><p> <strong>更新.js.erb</strong></p><pre> document.getElementById('&lt;%= dom_id(@facility_event_tracker, 'inline_form') %&gt;').remove() document.getElementById('&lt;%= dom_id(@facility_event_tracker, 'inline_form') %&gt;').innerHTML = &lt;%= j render "facility_event_trackers/facility_event_tracker", facility_event_tracker: @facility_event_tracker %&gt;" document.getElementById('&lt;%= dom_id(@facility_event_tracker) %&gt;').style.display = 'table-row'</pre><p> <strong>Rails 控制台错误</strong></p><p> // 部分无法重新渲染以进行更新</p><pre>ActionView::Tempalate::Error (undefined local variable or method `event' for #&lt;#&lt;Class:0x00000&gt;:0x00005&gt;): 1: &lt;div class="divTableCell"&gt;&lt;%= chart_tracker_grid_date(event.start_time) %&gt;... 2: &lt;div class="divTableCell"&gt;&lt;%= event.event_count %&gt;&lt;/div&gt; app/views/facility_event_trackers/_facility_event_tracker.html.erb:1 app/views/facility_event_trackers/update.js.erb</pre></div></class::0x000..> - ActionView::Template::Error (undefined local variable or method `event' for #<#<Class::0x000.. Rails 6 AJAX ActionView :: Template :: Error(未定义的方法`沉默&#39;为) - ActionView::Template::Error (undefined method `silence' for) Rails:ActionView :: Template :: Error - 未定义的方法&#39;comment&#39; - Rails: ActionView::Template::Error - undefined method 'comment' actionview :: template :: error(未定义的方法&#39;html_safe&#39;代表nil:NilClass) - actionview::template::error(undefined method 'html_safe' for nil:NilClass) Rails Minitest ActionView :: Template :: Error:nil:NilClas的未定义方法 - Rails Minitest ActionView::Template::Error: undefined method for nil:NilClas ActionView :: Template :: Error(nil:NilClass的未定义方法“ FirstName”): - ActionView::Template::Error (undefined method `FirstName' for nil:NilClass): ActionView :: Template :: Error:nil:NilClas的未定义方法&#39;children&#39; - ActionView::Template::Error: undefined method `children' for nil:NilClas Ruby错误了吗? 导致ActionView :: Template :: Error - 未定义的方法 - Ruby error any? cause an ActionView::Template::Error - undefined method ActionView :: Template :: Error(nil:NilClass的未定义方法“ strip!”) - ActionView::Template::Error (undefined method `strip!' for nil:NilClass)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM