summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/.project.rb.swobin0 -> 49152 bytes
-rw-r--r--app/models/project.rb12
2 files changed, 12 insertions, 0 deletions
diff --git a/app/models/.project.rb.swo b/app/models/.project.rb.swo
new file mode 100644
index 00000000000..5d264ccfaaa
--- /dev/null
+++ b/app/models/.project.rb.swo
Binary files differ
diff --git a/app/models/project.rb b/app/models/project.rb
index 3b565ef809a..4d2ff11cc11 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -86,6 +86,18 @@ class Project < ActiveRecord::Base
end
end
+ # checks if the language main language of the project changed
+ before_save :check_main_language
+ def check_main_language
+ if !repository.empty? && self.changed?
+ language = Linguist::Repository.new(
+ repository.rugged,
+ repository.rugged.head.target_id).language
+
+ self.main_language = language
+ end
+ end
+
ActsAsTaggableOn.strict_case_match = true
acts_as_taggable_on :tags