Commit 030ca2be320103668fa0f96d68b833a9f028111f
Committed by
Rodrigo Souto
1 parent
425f6c70
Exists in
master
and in
29 other branches
refactoring article creation
Showing
1 changed file
with
6 additions
and
2 deletions
Show diff stats
lib/api/v1/articles.rb
@@ -64,8 +64,12 @@ module API | @@ -64,8 +64,12 @@ module API | ||
64 | # POST api/v1/communites/:community_id/articles?private_toke=234298743290432&article[name]=title&article[body]=body | 64 | # POST api/v1/communites/:community_id/articles?private_toke=234298743290432&article[name]=title&article[body]=body |
65 | post do | 65 | post do |
66 | community = environment.communities.find(params[:community_id]) | 66 | community = environment.communities.find(params[:community_id]) |
67 | - article = community.articles.build(params[:article].merge(:last_changed_by => current_person)) | ||
68 | - article.type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] | 67 | + klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] |
68 | + article = klass_type.constantize.new(params[:article]) | ||
69 | + article.last_changed_by = current_person | ||
70 | + article.created_by= current_person | ||
71 | + article.profile = community | ||
72 | + | ||
69 | if !article.save | 73 | if !article.save |
70 | render_api_errors!(article.errors.full_messages) | 74 | render_api_errors!(article.errors.full_messages) |
71 | end | 75 | end |