# Naive question

**URL:** <https://www.ruby-forum.com/t/naive-question/133797>\
**Category:** Rails\
**Created:** [April 3, 2008, 6:50pm UTC](https://www.ruby-forum.com/t/naive-question/133797 "2008-04-03T18:50:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Stever](https://www.ruby-forum.com/u/Stever)\
**Post date:** [April 3, 2008, 6:50pm UTC](https://www.ruby-forum.com/t/naive-question/133797/1 "2008-04-03T18:50:04Z")

</div>

Got a naive question, and I don’t know what keywords to search for on  
google.

I have a webform that needs to query a database in realtime with  
javascript. So if I press a button, it will query a database and  
return the result to the webpage without reloading the webpage. It  
should use ajax.

I assume rails have some sort of ajax-y type of thing that makes this  
query possible. What is this called? I don’t know what terms to type  
into google.

---

<div class="post-metadata">

**Author:** ![Stever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Stever](https://www.ruby-forum.com/u/Stever)\
**Post date:** [April 3, 2008, 6:53pm UTC](https://www.ruby-forum.com/t/naive-question/133797/2 "2008-04-03T18:53:48Z")

</div>

the most simple way to do this would be link\_to\_remote  
[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000958](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000958)

this makes an ajax call to the controller/action on the server, which  
then can make the db query and render the results.  
but there are many commands and ways to do this, depending on your needs

---

<div class="post-metadata">

**Author:** ![Stever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Stever](https://www.ruby-forum.com/u/Stever)\
**Post date:** [April 4, 2008, 1:07am UTC](https://www.ruby-forum.com/t/naive-question/133797/3 "2008-04-04T01:07:37Z")

</div>

To do what, exactly?

Quoting is handy!

Julian.

Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) VIDEO #3  
OUT APRIL 6  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![Stever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Stever](https://www.ruby-forum.com/u/Stever)\
**Post date:** [April 4, 2008, 1:09am UTC](https://www.ruby-forum.com/t/naive-question/133797/4 "2008-04-04T01:09:58Z")

</div>

The thing you’re after is most likely observe\_field. Things to  
remember when using AJAX are that you need to include the default  
javascripts in your layout, and to look at the log files a lot when  
debugging it.

Using RJS templates is easier than using the :update argument on the  
observe\_field helper tag.

Julian.

Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) VIDEO #3  
OUT APRIL 6  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)
