From 209aa17c95256c0a883cb44a9f87a6a9f0dcd3c9 Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Mon, 3 Jun 2013 16:38:24 +0200 Subject: [PATCH] stories-table-add-search To get the search feature working, we need to update the controller side. Add a `show` method to `app/controllers/projects_controller.rb` and update the `` to use `@stories` as it's context: SHOW_PATCH There's a lot happening here, so we're just going to point you to appropriate manual chapters to explain the concepts. - [DRYML context switching](/manual/dryml-guide#the_implicit_context) - [Changing controller action behaviour](/manual/controllers#changing_action_behaviour) - [search and order_by scopes](/manual/scopes#static_scopes) - [find_instance](/manual/controller#find_instance) - [parse_sort_param](/manual/controller#parse_sort_param) --- app/controllers/projects_controller.rb | 8 ++++++++ app/views/projects/show.dryml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 210b07d..3c3b39b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -4,4 +4,12 @@ class ProjectsController < ApplicationController auto_actions :all + def show + @project = find_instance + @stories = @project.stories. + search(params[:search], :title). + order_by(parse_sort_param(:title, :status)) + hobo_show + end + end diff --git a/app/views/projects/show.dryml b/app/views/projects/show.dryml index f62b0b2..0ea6a1d 100644 --- a/app/views/projects/show.dryml +++ b/app/views/projects/show.dryml @@ -1,6 +1,6 @@ - + No stories match your criteria