# Live search in Rails

**URL:** <https://www.ruby-forum.com/t/live-search-in-rails/54660>\
**Category:** Rails\
**Created:** [March 11, 2006, 6:03pm UTC](https://www.ruby-forum.com/t/live-search-in-rails/54660 "2006-03-11T18:03:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xcandyman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/aca169/32.png) [@xcandyman](https://www.ruby-forum.com/u/xcandyman)\
**Post date:** [March 11, 2006, 6:03pm UTC](https://www.ruby-forum.com/t/live-search-in-rails/54660/1 "2006-03-11T18:03:17Z")

</div>

Hi i’ve been trying to implement live search on rails but Im having  
trouble Im using a tutorial at:

[http://www.joestelmach.com/blog/live\_search\_with\_ruby\_on\_rails](http://www.joestelmach.com/blog/live_search_with_ruby_on_rails)

But im getting a syntaxerror on line 1

‘1: \<% if @items && @items.length \> 0% \>’

I cant fathom what im doing wrong, is that line calling a column in  
my database called items?

Here’s the error

./script/…/config/…/app/views/domain/search.rhtml:1: syntax error  
./script/…/config/…/app/views/domain/search.rhtml:3: syntax error  
\<% for domain in @items ; \_erbout.concat “\n”  
^  
./script/…/config/…/app/views/domain/search.rhtml:3: syntax error  
\<% for domain in @items ; \_erbout.concat “\n”  
^  
./script/…/config/…/app/views/domain/search.rhtml:6: syntax error  
./script/…/config/…/app/views/domain/search.rhtml:7: syntax error  
./script/…/config/…/app/views/domain/search.rhtml:8: syntax error  
:action =\> “show”, :id =\> domain.id ).to\_s); \_erbout.concat “\n”  
^  
./script/…/config/…/app/views/domain/search.rhtml:12: syntax error  
elsif @mark\_term && @mark\_term.length \> 0 ; \_erbout.concat “\n”  
^

Thanks

---

<div class="post-metadata">

**Author:** ![xcandyman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/aca169/32.png) [@xcandyman](https://www.ruby-forum.com/u/xcandyman)\
**Post date:** [March 11, 2006, 6:16pm UTC](https://www.ruby-forum.com/t/live-search-in-rails/54660/2 "2006-03-11T18:16:35Z")

</div>

On Mar 11, 2006, at 18:03, Ste H. wrote:

> Hi i’ve been trying to implement live search on rails but Im having  
> trouble Im using a tutorial at:
> 
> [http://www.joestelmach.com/blog/live\_search\_with\_ruby\_on\_rails](http://www.joestelmach.com/blog/live_search_with_ruby_on_rails)
> 
> But im getting a syntaxerror on line 1
> 
> ‘1: \<% if @items && @items.length \> 0% \>’

There’s an invalid space between “%” and “\>”:

```
 <% if @items && @items.length > 0 %>

```

– fxn

---

<div class="post-metadata">

**Author:** ![xcandyman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/aca169/32.png) [@xcandyman](https://www.ruby-forum.com/u/xcandyman)\
**Post date:** [March 11, 2006, 6:25pm UTC](https://www.ruby-forum.com/t/live-search-in-rails/54660/3 "2006-03-11T18:25:32Z")

</div>

Thanks that helped but got another error

compile error  
./script/…/config/…/app/views/find/search.rhtml:6: syntax error  
./script/…/config/…/app/views/find/search.rhtml:7: syntax error  
./script/…/config/…/app/views/find/search.rhtml:8: syntax error  
:action =\> “show”, :id =\> domain.id ).to\_s); \_erbout.concat “\n”  
^

Extracted source (around line #6):

3: \<% for domain in @items %\>  
4:

-   
5: \<%= link\_to  
6: @mark\_term ? highlight(domain.id, @mark\_term) : h(domain.id),  
7: :controller =\> “domain”,  
8: :action =\> “show”, :id =\> domain.id %\>  
9: 

steve

---

<div class="post-metadata">

**Author:** ![xcandyman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/aca169/32.png) [@xcandyman](https://www.ruby-forum.com/u/xcandyman)\
**Post date:** [March 12, 2006, 12:08pm UTC](https://www.ruby-forum.com/t/live-search-in-rails/54660/4 "2006-03-12T12:08:54Z")

</div>

You probably need the first argument to link\_to on the same line as the  
method call:

\<%= link\_to @mark\_term ? highlight(domain.id, @mark\_term) :  
h(domain.id),  
:controller =\> “domain”,  
:action =\> “show”, :id =\> domain.id %\>

-Jonathan.

---

<div class="post-metadata">

**Author:** ![xcandyman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/aca169/32.png) [@xcandyman](https://www.ruby-forum.com/u/xcandyman)\
**Post date:** [March 12, 2006, 12:56pm UTC](https://www.ruby-forum.com/t/live-search-in-rails/54660/5 "2006-03-12T12:56:02Z")

</div>

Hi Jonathan,

I’ve worked out what was wrong it was calling an action ‘show’ that  
didnt exist.

Thanks

Steve

Jonathan V. wrote:

> You probably need the first argument to link\_to on the same line as the  
> method call:
> 
> \<%= link\_to @mark\_term ? highlight(domain.id, @mark\_term) :  
> h(domain.id),  
> :controller =\> “domain”,  
> :action =\> “show”, :id =\> domain.id %\>
> 
> -Jonathan.
