diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb index 12aa62b..6cac4f9 100644 --- a/app/controllers/glossary_terms_controller.rb +++ b/app/controllers/glossary_terms_controller.rb @@ -5,8 +5,12 @@ class GlossaryTermsController < ApplicationController def index @glossary_terms = GlossaryTerm.where(project_id: @project.id) - @glossary_terms = @glossary_terms.search_by_name(params[:index]) unless params[:index].nil? - @grouping = params[:grouping] + if not params[:index].nil? + @glossary_terms = @glossary_terms.search_by_name(params[:index]) + elsif not params[:index_rubi].nil? + @glossary_terms = @glossary_terms.search_by_rubi(params[:index_rubi]) + end + @grouping = params[:grouping] unless params[:grouping].nil? end def new diff --git a/app/models/glossary_term.rb b/app/models/glossary_term.rb index eee2c69..f044385 100644 --- a/app/models/glossary_term.rb +++ b/app/models/glossary_term.rb @@ -6,4 +6,8 @@ class GlossaryTerm < ActiveRecord::Base where 'name like ?', "#{sanitize_sql_like(keyword)}%" } + scope :search_by_rubi, -> (keyword) { + where 'rubi like ?', "#{sanitize_sql_like(keyword)}%" + } + end diff --git a/app/views/glossary_terms/_sidebar.html.erb b/app/views/glossary_terms/_sidebar.html.erb index 4232024..efe4cd4 100644 --- a/app/views/glossary_terms/_sidebar.html.erb +++ b/app/views/glossary_terms/_sidebar.html.erb @@ -35,4 +35,15 @@ <% end %> +
+ <%= link_to char, project_glossary_terms_path(index_rubi: char) %> + | + <% end %> +