In the console:
>> act = Activity.find_by_id(37)
=> #<Activity id: 37, created_at: "2008-07-30 05:08:41",
updated_at:
"2008-07-30 05:08:41", location_id: 1, scheduled_at:
nil>>> act.location
=> #<Location id: 1, name: "Bar Austin", genre: 1, age_group: 1,
notes:
"First Bar Added to Test", created_at: "2008-07-29
04:15:47",
updated_at: "2008-07-29 04:15:47", street1: "402 E. 6th
Street",
street2: nil, city: "Austin", state: "TX", zip:
"78701", phone_number:
"(512) 476-3139", image_url: "locations/bars/image1.jpg",
website_url:
nil, average_rating: 3.0>
------------
In the view when I try to do:
<%= debug(@activities) %>
<% for activity in @activities %>
<%= debug(activity.location) %>
<% end %>
I get the error:
NoMethodError in Public#index
Showing public/index.fbml.erb where line #7 raised:
undefined method `location'' for #<Class:0xb7106258>
Extracted source (around line #7):
4:
5: <% for activity in @activities %>
6:
7: <%= debug(activity.location) %>
Taking out the ''debug(activity.location)'' line and just
showing the
debug output of the activities array:
---
- - !ruby/object:Activity
attributes:
updated_at: 2008-07-30 23:22:49
activity_id: "52"
id: "52"
location_id: "1"
user_id: "1"
scheduled_at: 2008-07-25 04:00:00
created_at: 2008-07-30 23:22:49
attributes_cache: {}
- !ruby/object:Activity
attributes:
updated_at: 2008-07-31 04:14:18
activity_id: "54"
id: "54"
location_id: "1"
user_id: "1"
scheduled_at: 2008-07-31 04:00:00
created_at: 2008-07-31 04:14:18
attributes_cache: {}
- - !ruby/object:Activity
attributes:
updated_at: 2008-07-31 02:34:23
activity_id: "53"
id: "53"
location_id: "4"
user_id: "2"
scheduled_at: 2008-08-01 04:00:00
created_at: 2008-07-31 02:34:23
attributes_cache: {}
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---