Commit 7807c91382d2a09ba79e559b5bca64580c6a66f7
Committed by
Rodrigo Souto
1 parent
6522edbf
Exists in
master
and in
21 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 | 64 | # POST api/v1/communites/:community_id/articles?private_toke=234298743290432&article[name]=title&article[body]=body |
65 | 65 | post do |
66 | 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 | 73 | if !article.save |
70 | 74 | render_api_errors!(article.errors.full_messages) |
71 | 75 | end | ... | ... |