[logaling-commit] logaling/logaling-server [github-project-related-to-user] Extract User#priority_glossary

Zurück zum Archiv-Index

SHIMADA Koji null+****@clear*****
Tue Sep 25 19:15:39 JST 2012


SHIMADA Koji	2012-09-25 19:15:39 +0900 (Tue, 25 Sep 2012)

  New Revision: f3f08cce9aa77639ec6800eb96edec160b8bb2c9
  https://github.com/logaling/logaling-server/commit/f3f08cce9aa77639ec6800eb96edec160b8bb2c9

  Merged 971b851: Merge pull request #14 from logaling/prioritize-the-search

  Log:
    Extract User#priority_glossary

  Modified files:
    app/controllers/search_controller.rb
    app/models/user.rb

  Modified: app/controllers/search_controller.rb (+2 -3)
===================================================================
--- app/controllers/search_controller.rb    2012-09-25 19:06:28 +0900 (77137a8)
+++ app/controllers/search_controller.rb    2012-09-25 19:15:39 +0900 (549cbd7)
@@ -1,9 +1,8 @@
 class SearchController < ApplicationController
   def index
     @query = params[:query]
+    priority_glossary = signed_in? ? current_user.priority_glossary : nil
 
-    user_config = signed_in? ? UserConfig.find_by_user_id(current_user.id) : nil
-    glossary = user_config ? user_config.glossary : nil
-    @terms = LogalingServer.repository.lookup(@query, glossary)
+    @terms = LogalingServer.repository.lookup(@query, priority_glossary)
   end
 end

  Modified: app/models/user.rb (+4 -0)
===================================================================
--- app/models/user.rb    2012-09-25 19:06:28 +0900 (cf7b1ef)
+++ app/models/user.rb    2012-09-25 19:15:39 +0900 (ffc5f25)
@@ -13,4 +13,8 @@ class User < ActiveRecord::Base
 
   has_many :user_glossaries
   has_one :user_config
+
+  def priority_glossary
+    user_config ? user_config.glossary : nil
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



More information about the logaling-commit mailing list
Zurück zum Archiv-Index