Commit c282b70298511641822e1975c147ecbf72fcc197

Authored by Victor Costa
1 parent c7dc5dc4

api: avoid problems when loading article descendant

This is a temporary workaround. The real solution is to enable eager
load again.
Showing 1 changed file with 3 additions and 3 deletions   Show diff stats
lib/noosfero/api/helpers.rb
... ... @@ -114,7 +114,6 @@ require_relative '../../find_by_contents'
114 114 end
115 115 end
116 116  
117   - ARTICLE_TYPES = ['Article'] + Article.descendants.map{|a| a.to_s}
118 117 TASK_TYPES = ['Task'] + Task.descendants.map{|a| a.to_s}
119 118  
120 119 def find_article(articles, id)
... ... @@ -125,8 +124,9 @@ require_relative '../../find_by_contents'
125 124 def post_article(asset, params)
126 125 return forbidden! unless current_person.can_post_content?(asset)
127 126  
128   - klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type]
129   - return forbidden! unless ARTICLE_TYPES.include?(klass_type)
  127 + klass_type= params[:content_type].nil? ? TinyMceArticle.name : params[:content_type]
  128 + article_types = ['Article'] + Article.descendants.map{|a| a.to_s}
  129 + return forbidden! unless article_types.include?(klass_type)
130 130  
131 131 article = klass_type.constantize.new(params[:article])
132 132 article.last_changed_by = current_person
... ...