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`.id `categories_posts`.category_id WHERE ((`categories_posts`.post_id 1)) Extracted source (around line #19): 16: <td><%= post.created_at.strftime(''%m/%d/%y %I:%m %p'') %></td> 17: <td><%= h(post.title) %></td> 18: <td><%= h(post.author.display_name) if post.author %></td> 19: <td><%= post.categories.collect {|cat| [cat.name] }.join(",") %> 20: <td><%= h(post.status) %></td> 21: <td><%= 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 post_id. Regards. Franco Catena. On Apr 24, 11:51 am, haneef5k <hanee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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`.id > `categories_posts`.category_id WHERE ((`categories_posts`.post_id > 1)) > > Extracted source (around line #19): > > 16: <td><%= post.created_at.strftime(''%m/%d/%y %I:%m %p'') %></td> > 17: <td><%= h(post.title) %></td> > 18: <td><%= h(post.author.display_name) if post.author %></td> > 19: <td><%= post.categories.collect {|cat| [cat.name] }.join(",") > %> > 20: <td><%= h(post.status) %></td> > 21: <td><%= post.comments_count %> > > pls help me,, im new to RoR..??
Hi, 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 confusssed.. pls help me.. haneef5k-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org On Apr 24, 9:12 pm, Franco Catena <francocat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > post_id. > > Regards. > > Franco Catena. > > On Apr 24, 11:51 am, haneef5k <hanee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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`.id > > `categories_posts`.category_id WHERE ((`categories_posts`.post_id > > 1)) > > > Extracted source (around line #19): > > > 16: <td><%= post.created_at.strftime(''%m/%d/%y %I:%m %p'') %></td> > > 17: <td><%= h(post.title) %></td> > > 18: <td><%= h(post.author.display_name) if post.author %></td> > > 19: <td><%= post.categories.collect {|cat| [cat.name] }.join(",") > > %> > > 20: <td><%= h(post.status) %></td> > > 21: <td><%= post.comments_count %> > > > pls help me,, im new to RoR..??- Hide quoted text - > > - Show quoted text -
You can read the Agile Web Development With Rails (http:// www.pragprog.com/titles/rails3), is a very good book. It explains step by step the framework and a very common (but usefull) workflow. Regards. Franco Catena. On Apr 24, 3:20 pm, haneef5k <hanee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > 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 > confusssed.. > pls help me.. > > hanee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > On Apr 24, 9:12 pm, Franco Catena <francocat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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 > > post_id. > > > Regards. > > > Franco Catena. > > > On Apr 24, 11:51 am, haneef5k <hanee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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`.id > > > `categories_posts`.category_id WHERE ((`categories_posts`.post_id > > > 1)) > > > > Extracted source (around line #19): > > > > 16: <td><%= post.created_at.strftime(''%m/%d/%y %I:%m %p'') %></td> > > > 17: <td><%= h(post.title) %></td> > > > 18: <td><%= h(post.author.display_name) if post.author %></td> > > > 19: <td><%= post.categories.collect {|cat| [cat.name] }.join(",") > > > %> > > > 20: <td><%= h(post.status) %></td> > > > 21: <td><%= post.comments_count %> > > > > pls help me,, im new to RoR..??- Hide quoted text - > > > - Show quoted text -