montera34 / pageonex

PageOneX. Analyzing front pages
http://pageonex.com
GNU Affero General Public License v3.0
54 stars 13 forks source link

"NoMethodError in Threads#create" when creating a thread #123

Closed numeroteca closed 11 years ago

numeroteca commented 11 years ago

I am not able to replicate/isolate this problem, but this is what I get sometimes when I try to create a new thread in the dev sever:

NoMethodError in Threads#create

Showing /var/www/pageonex/dev/app/views/threads/new.html.erb where line #89 raised:

undefined method `name_with_country' for "Argentina - Buenos Aires Económico":String
Extracted source (around line #89):

89:         <%= select_tag :media, options_from_collection_for_select(@media, "id", "name_with_country"),  :multiple => true ,"rel" => "popover", "data-content"  => "To select multiple newspapers: Hold Ctrl + select the newspaper, release the Ctrl with scrolling and hold it again before any other selection", "data-original-title" => "Select Multiple Newspapers" , style: "height: 300px;width: 300px;", :class=>"js_validate" %>

Rails.root: /var/www/pageonex/dev

Application Trace  
app/views/threads/new.html.erb:89:in `block in _app_views_threads_new_html_erb__1443160972600925135_15627200'
app/views/threads/new.html.erb:18:in `_app_views_threads_new_html_erb__1443160972600925135_15627200'
app/controllers/threads_controller.rb:90:in `create'

Parameters:
{"utf8"=>"✓",
 "authenticity_token"=>"BualqP4O7xg8Du7diMrRvQnZ5pYalRddpRe70f1szuI=",
 "threadx"=>{"thread_display_name"=>"Test open thread for media lab festival",
 "start_date"=>"02/04/2013",
 "end_date"=>"04/04/2013",
 "category"=>"social,
 15M",
 "description"=>"sdaf"},
 "status"=>"closed",
 "media"=>["1",
 "614"],
 "selected_newspapers"=>"",
 "code_id"=>[""],
 "topic_name_0"=>"test",
 "topic_color_0"=>"#309c0f",
 "topic_description_0"=>"test desc",
 "topic_deleted_0"=>"",
 "topic_count"=>"1",
 "validation_error"=>"false",
 "empty_topic"=>"",
 "empty_media"=>""}
rahulbot commented 11 years ago

I think I fixed this in a previous commit - some of the code was loading @media as a list of strings, instead of a list of Media model objects. I changed it to all load Media model objects the same way so this shouldn't show up anymore