Permalink
Browse files

reduced instanciated AR objects for search

  • Loading branch information...
1 parent 7e46b0c commit 4d3d971452086f375eed953f66f25cfe6e622281 @hukl committed Dec 1, 2009
View
3 app/controllers/search_controller.rb
@@ -3,8 +3,7 @@ def index
@page = Page.new
search_term = params[:search_term]
if search_term and not search_term.empty?
- nodes = Node.search(params[:search_term])
- @results = nodes.map {|node| node.head}
+ @results = Node.search(params[:search_term], :include => :head)
end
end
View
4 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>
View
8 app/views/search/index.html.erb
@@ -1,13 +1,11 @@
-<h2>Suche</h2>
-
<% 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 %>
<%=
render(
- :partial => 'custom/partials/article',
+ :partial => 'search_result',
:collection => @results,
- :as => :page
+ :as => :node
)
%>

0 comments on commit 4d3d971

Please sign in to comment.