Listing of Category error

Im trying to see posts index page, In tat im showing category list, im
using collect method it show error…

ActiveRecord::StatementInvalid in Posts#index
Showing app/views/posts/index.html.erb where line #19 raised:

Mysql::Error: Unknown column ‘categories_posts.category_id’ in ‘on
clause’: SELECT categories.* FROM categories INNER JOIN
categories_posts ON =
categories_posts.category_id WHERE ((categories_posts.post_id =

Extracted source (around line #19):


<%= post.created_at.strftime(’%m/%d/%y %I:%m %p’) %>
17: <%= h(post.title) %>
18: <%= h( if %>
19: <%= post.categories.collect {|cat| [] }.join(",")
20: <%= h(post.status) %>
21: <%= post.comments_count %>

pls help me, im new to RoR…??

You must declare a has_many :categories in the Post model and a
belongs_to :post in the Category model (if the category table has a
post_id column, if not keep reading). If you don’t do that, you need
to create a categories_posts table with two columns: category_id and a


Franco C…


Im new to Ror, i want to do some userful website can u tell me ur
advice and wat steps i should to take basically in Ruby on Rails…??
then im trying to understand tat ( models, controller, action ) it
pls help me…

[email protected]

You can read the Agile Web D. With Rails (http://, is a very good book. It explains step
by step the framework and a very common (but usefull) workflow.


Franco C…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs