So I am making an app to manage projects and its task, using a tutorial I have made some basic stuff.
Now I want to add a timeline to my page, so I wrote this in my pr_list.rb (model file)
def timeline
@pr_lists.each do |pr_list|
pr_list.pr_items.each do |pr_item|
if pr_item.completed?
@timeline = "#{pr_item.descrpition}: {#{pr_item.completed_at}}"
end
end
end
end
And i called it in my pr_list/views/index page.
<h1><%= pr_list.timeline %></h1>
but I get
NameError (undefined local variable or method `pr_list' for #<ActionView::Base:0x00000000029fb8>
Did you mean? @pr_lists")
At this point even if I just code it like to output a string, it just does not work.
if I try any other things, it gives me a NoMethodError
while the rest of the methods work. and the above code also works if I write it in HTML.ERB index file as an embedded ruby.
I am new to Ruby on Rails.