Hello - am still very new and need any help available
I have a user model
class User < ActiveRecord::Base
has_many :calls
has_many :visits
has_many :calls_visited,
:through => :visits,
:source => :call
has_many:calls do
def recent
find :all, :order => ‘id DESC’, :limit => 5
end
end
end
and I have a view to display the calls for a particular user using
a partial
The view is
My Dashboard - <%= @current_user.login.capitalize %>
You have no calls
- <%= link_to 'Add a call to get started!', { :controller => "calls", :action => "new" } %>
<h3>My Recent Calls</h3>
<%= render :partial => 'user/
recentCalls’, :collection => @current_user.calls.recent %>
<% end %>
You have no visits
- <%= link_to 'Add a visit to get started!', { :controller => "visits", :action => "new" } %>
My Recent Visits
-
<% @current_user.visits.each do |c| %>
- <%= link_to c.name, {:controller => 'visits', :action => 'show', :id => c.id} -%> - <%= c.date %> <% end %>
and the partial that doesn’t work is the user/recentCalls partial
<%= call.created_at.to_formatted_s(:long) %>
<%= call.name %>
when the view evaluates <% if@current_user.calls.blank? %> it goes
through to the
<%= render :partial => ‘user/recentCalls’, :collection =>
@current_user.calls.recent %>
and throws an error NameError in User#dashboard
Showing user/_recentCalls.rhtml where line #3 raised:
undefined local variable or method `call’ for #<ActionView::Base:
0x2658158>
Extracted source (around line #3):
1:
2:
3:
<%= call.created_at.to_formatted_s(:long) %>
4:
<%= call.name %>
5:
Trace of template inclusion: /user/dashboard.rhtm
Any ideas on why it doesn’t get the call? I’ve tried
current_user.call.created_at… and @current_user and @call et. .
Anyway any help will be appreciated