Note that there are some explanatory texts on larger screens.

plurals
  1. PONameError - undefined local variable or method when calling created method in controller
    primarykey
    data
    text
    <p>When trying to access the Reasons Index page</p> <pre><code>NameError in Reasons#index Showing /home/alec/workspace/rails/nwis/app/views/reasons/index.html.erb where line #26 raised: undefined local variable or method `upvote_reason' for #&lt;#&lt;Class:0x000000023d9940&gt;:0x000000023d3298&gt; Extracted source (around line #26): 23: &lt;td&gt;&lt;%= link_to 'Show', reason %&gt;&lt;/td&gt; 24: &lt;td&gt;&lt;%= link_to 'Edit', edit_reason_path(reason) %&gt;&lt;/td&gt; 25: &lt;td&gt;&lt;%= link_to 'Destroy', reason, :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/td&gt; 26: &lt;td&gt;&lt;%= link_to "Vote up", :action =&gt; upvote_reason, :id =&gt; reason.id %&gt;&lt;/td&gt; 27: &lt;/tr&gt; 28: &lt;% end %&gt; 29: &lt;/table&gt; Rails.root: /home/alec/workspace/rails/nwis Application Trace | Framework Trace | Full Trace app/views/reasons/index.html.erb:26:in `block in _app_views_reasons_index_html_erb__2084449067598068298_18776480__4598497200926455905' app/views/reasons/index.html.erb:16:in `each' app/views/reasons/index.html.erb:16:in `_app_views_reasons_index_html_erb__2084449067598068298_18776480__4598497200926455905' app/controllers/reasons_controller.rb:7:in `index' </code></pre> <p>The line in the view:</p> <pre><code>&lt;td&gt;&lt;%= link_to "Vote up", :action =&gt; upvote_reason, :id =&gt; reason.id %&gt;&lt;/td&gt; </code></pre> <p>The method in the controller:</p> <pre><code>def upvote_reason @reason = Reason.find(params[:id]) @reason.upvote += 1 @reason.save redirect_to reason_path end </code></pre> <p>Admittedly, I'm pretty new at Rails, but I feel like I'm on the verge of it clicking, once I can figure out how to properly interact with the controller. If someone can point me in the right direction to a tutorial that covers this topic well, I'd be glad to check it out if this is too basic of a question. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload