Ruby on Rails Tuesday, December 14, 2010

Hi guys, I'm following the Beginning Rails 3 Book, I've problems with the many to many relationship between Article-Category, when I try to create or show a article.


Please help me, I'm new with Rails.

Regards,

ActiveRecord::StatementInvalid in Articles#new

Showing I:/Labs/RailsProjects/blog/app/views/articles/_form.html.erb where line #27 raised:

 SQLite3::SQLException: no such column: articles_categories.category_id: SELECT "categories".id FROM "categories" INNER JOIN "articles_categories" ON "categories".id = "articles_categories".category_id WHERE ("articles_categories".article_id = NULL )

Extracted source (around line #27):

24:       <%= f.label "Categories" %>
 25:       <% for category in Category.all %>
26:         <%= check_box_tag 'article[category_ids][]', category.id,
 27:           @article.category_ids.include?(category.id), :id => dom_id(category) %>
28:         <%= label_tag dom_id(category), category.name, :class => "check_box_label" %>
 29:       <% end %>
30:     </p>

Trace of template inclusion: app/views/articles/new.html.erb

Rails.root: I:/Labs/RailsProjects/blog

app/views/articles/_form.html.erb:27:in `block (2 levels) in _app_views_articles__form_html_erb___743271537_14143752__942053146'
app/views/articles/_form.html.erb:25:in `each'
app/views/articles/_form.html.erb:25:in `block in _app_views_articles__form_html_erb___743271537_14143752__942053146'
app/views/articles/_form.html.erb:1:in `_app_views_articles__form_html_erb___743271537_14143752__942053146'
app/views/articles/new.html.erb:6:in `_app_views_articles_new_html_erb__987918893_24332892_280057368'
app/controllers/articles_controller.rb:20:in `new'

Request

Parameters

:
 None

Response

Headers

:
None

--
TSU. Amador Cuenca

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment