Hello all,
I about to pull my hair out.
I have two models "Activities" and "Activity_types"
Activities
----------
id
name
activity_type_id
Activity_types
--------------
id
name
- Associations -
class Activity < ActiveRecord::Base
has_many :activity_types
end
class ActivityType < ActiveRecord::Base
belongs_to :activity
end
- activities_controller -
def index
@activities = Activity.find(:all, :joins => :activity_types)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @activities }
end
end
- index.html.erb -
<h1>Listing activities</h1>
<table class="activities">
<% @activityTypeTitle.each do |title| %>
<tr><th><h3><%= title.name %></h3></th></tr>
<tr>
<th>Name</th>
<th colspan="3">Action</th>
</tr>
<% @budgetActivities.each do |activity| %>
<tr>
<td><%=h activity.name %></td>
<td><%= link_to 'Show', activity %></td>
<td><%= link_to 'Edit', edit_activity_path(activity) %></td>
<td><%= link_to 'Destroy', activity, :confirm => 'Are you sure?',
:method => :delete %></td>
</tr>
<% end %>
<tr><td><%= link_to "New Activity", new_activity_path %></td></tr>
<% end %>
</table>
<br />
All I'm trying to do is list the 'types' as a header of a table with the
activities in rows.
When I try to do the join, I get...
"SQLite3::SQLException: no such column: activity_types.activity_id:
SELECT "activities".* FROM "activities" INNER JOIN "activity_types" ON
activity_types.activity_id = activities.id"
Thank you for any help with this.
JohnM
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.