Skip to content

Commit

Permalink
updated site controller to return sites in the order of the fits id
Browse files Browse the repository at this point in the history
  • Loading branch information
juddin927 committed Nov 23, 2023
1 parent 66a9dfc commit a03be4b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
3 changes: 1 addition & 2 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ def index
@sites = Site.order(:fits_id).all
@navigation_crumbs = [["Home", root_path]]
@sites = if params[:query].present?
# Site.where('name LIKE ? OR fits_id LIKE ?', "%#{params[:query]}%", "%#{params[:query]}%")
Site.where('name LIKE ? OR fits_id LIKE ? OR id IN (
SELECT sn.site_id
FROM subnets s
INNER JOIN shared_networks sn ON s.shared_network_id = sn.id
WHERE s.cidr_block LIKE ?
)', "%#{params[:query]}%", "%#{params[:query]}%", "%#{params[:query]}%")
else
Site.all
Site.order(:fits_id).all
end
end

Expand Down
6 changes: 0 additions & 6 deletions app/views/sites/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
<%= submit_tag "Search", class: "govuk-button", "data-module" => "govuk-button" %>
<% end %>
</div>
<!-- <div style="text-align: right; margin-bottom: 10px;">-->
<%#= form_tag(dhcp_path, method: :get, class: "govuk-form") do %>
<%#= text_field_tag :query, params[:query], placeholder: "Search sites..." %>
<%#= submit_tag "Search", class: "govuk-button" %>
<%# end %>
<!-- </div>-->
<% if can? :create, Site %>
<%= link_to "Create a new site", new_site_path, class: "govuk-button" %>
<% end %>
Expand Down

0 comments on commit a03be4b

Please sign in to comment.