Reputation: 73
I'm getting an argument error and I am not to sure why. I am still fairly new to using Rails and programming overall. I am currently working on my index page and am just trying to get the description displayed. Below is the view and controller. I am not sure why t.description
is being expected to have more than one argument. Is this because of strong params?
View:
<h1> All Tea Blends </h1>
<% @teas.each do |t| %>
<h2><%= link_to t.flavor, tea_path(t.id)%> - <%= t.brand.name %></h2>
<% link_to "Write a review", new_tea_review_path%>
<% end %>
<div>
<p><%= t.description %></p>
</div>
Controller:
class TeasController < ApplicationController
def index
@teas = Tea.order_by_rating.includes(:brand)
end
end
Upvotes: 1
Views: 28
Reputation: 2695
t.description
is outside of the loop. Not sure why you'd get wrong number of arguments (t is also used for translations, though). Just move it inside the loop...
<% @teas.each do |t| %>
<h2><%= link_to t.flavor, tea_path(t.id) %> - <%= t.brand.name %></h2>
<% link_to "Write a review", new_tea_review_path %>
<div>
<p><%= t.description %></p>
</div>
<% end %>
I'd also recommed changing your loop variable to tea
instead of t
. Its more descriptive and avoids conflicts.
Upvotes: 1