Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
msdundar committed Jul 14, 2018
1 parent f8cc193 commit 1bacc1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
20 changes: 8 additions & 12 deletions app/helpers/apa_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ module ApaHelper
def apa_citation(article)
title = article.title.capitalize_all

"#{authors_in_apa_format(article)}. #{title}. #{article.journal}, #{article.volume}(#{article.issue}), \
#{article.first_page}-#{article.last_page}"
"#{authors_in_apa_format(article)}. (#{article.year}). #{title}. #{article.journal}, \
#{article.volume}(#{article.issue}), #{article.first_page}-#{article.last_page}"
end

def authors_in_apa_format(article)
apa_authors = []

article.authors.split(',').each do |author|
last_name = author.split(' ')[0].capitalize_all
first_name = author.split(' ')[1..-1].map! { |a| a[0] }.join('. ')

apa_authors << ["#{last_name}, #{first_name}"]
end

apa_authors.join(' & ')
article.authors.split(',').map do |author|
names = author.split
last_name = names.shift.capitalize_all
first_name = names.map(&:first).join('. ')
"#{last_name}, #{first_name}"
end.join(' & ')
end
end
2 changes: 1 addition & 1 deletion app/models/academic_studies/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ def self.unique_count
end

def self.most_recent
order(created_at: :desc).first(10)
order(created_at: :desc).limit(10)
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def accounts
end

def self.most_publishing
order('articles_count desc').first(10)
order('articles_count desc').limit(10)
end
end

0 comments on commit 1bacc1c

Please sign in to comment.