Skip to content

Commit

Permalink
reduced instanciated AR objects for search
Browse files Browse the repository at this point in the history
  • Loading branch information
hukl committed Dec 1, 2009
1 parent 7e46b0c commit 4d3d971
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions app/controllers/search_controller.rb
Expand Up @@ -3,8 +3,7 @@ def index
@page = Page.new @page = Page.new
search_term = params[:search_term] search_term = params[:search_term]
if search_term and not search_term.empty? if search_term and not search_term.empty?
nodes = Node.search(params[:search_term]) @results = Node.search(params[:search_term], :include => :head)
@results = nodes.map {|node| node.head}
end end
end end


Expand Down
4 changes: 4 additions & 0 deletions app/views/search/_search_result.html.erb
@@ -0,0 +1,4 @@
<div class="article_partial">
<h2 class="headline"><%= link_to node.head.title, content_path(node.unique_path) %></h2>
<p class="excerpt"><%= node.head.abstract %></p>
</div>
8 changes: 3 additions & 5 deletions app/views/search/index.html.erb
@@ -1,13 +1,11 @@
<h2>Suche</h2>

<% if params[:search_term] %> <% if params[:search_term] %>
<h3>Suchergebnisse für Suchbegriff: <%=h params[:search_term] %></h3> <h2>Suchergebnisse für Suchbegriff: <%=h params[:search_term] %></h2>
<% end %> <% end %>
<%= <%=
render( render(
:partial => 'custom/partials/article', :partial => 'search_result',
:collection => @results, :collection => @results,
:as => :page :as => :node
) )
%> %>

0 comments on commit 4d3d971

Please sign in to comment.