Skip to content

Commit

Permalink
Preserves collection select option :)
Browse files Browse the repository at this point in the history
  • Loading branch information
eburch2 committed Aug 11, 2016
1 parent 4574380 commit 3d78c40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/controllers/data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ def index

my_id = params[:Search_Group][:group_id]

# if any of the groups are selected besides the blank
if my_id != ""

# look up the row with our ID, grab only the children columns, take the first index of the array, and then make an array out of the string
@columns = SearchGroup.where(id: my_id).pluck(:children_columns)[0].split(", ")

else
@columns = Datum.column_names
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/data/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ header {
<center>
<!-- Code for the category combobox, search bar, and search button -->
<%= form_tag data_path, :method => 'get', enforce_utf8: true do %>
<%= collection_select :Search_Group, :group_id, SearchGroup.all.order(:group_name), :id, :group_name, { include_blank: 'School Profile' } %>
<%= collection_select :Search_Group, :group_id, SearchGroup.all.order(:group_name), :id, :group_name, { include_blank: 'School Profile', selected: params[:Search_Group][:group_id] } %>
<%= text_field_tag :search, params[:search], maxlength: 300, placeholder: "Search by any keyword or school number", id: "searchBar" %>
<%= submit_tag "Search", :name => nil %>
<% end %>
Expand Down

0 comments on commit 3d78c40

Please sign in to comment.