Permalink
Browse files

Using the plugin in the application

  • Loading branch information...
1 parent e5ff81a commit 660550db207a8904de15c26c987b8178ececc5e7 @ccjr committed May 6, 2010
View
7 app/controllers/articles_controller.rb
@@ -1,5 +1,10 @@
class ArticlesController < ApplicationController
- before_filter :authenticate, :except => [:index, :show, :notify_friend]
+ before_filter :authenticate, :except => [:index, :show, :notify_friend, :search]
+
+ def search
+ @articles = Article.search(params[:keyword])
+ render :action => 'index'
+ end
# GET /articles
# GET /articles.xml
View
6 app/views/articles/_search.html.erb
@@ -0,0 +1,6 @@
+<% form_tag search_articles_path, :method => :get do %>
+ <p>
+ Search
+ <%= text_field_tag :keyword, params[:keyword] %>
+ </p>
+<% end %>
View
1 app/views/layouts/application.html.erb
@@ -20,6 +20,7 @@
<%= link_to t('sessions.login'), login_path %>
<% end %>
</div>
+ <%= render 'articles/search' %>
</div>
<div id="main">
<%= content_tag(:p, notice, :class => 'notice') if notice.present? %>
View
3 config/routes.rb
@@ -4,6 +4,9 @@
member do
post :notify_friend
end
+ collection do
+ get :search
+ end
resources :comments
end
resources :users

0 comments on commit 660550d

Please sign in to comment.