# Ajax on rails

**URL:** <https://www.ruby-forum.com/t/ajax-on-rails/147867>\
**Category:** Rails\
**Created:** [September 6, 2008, 10:36am UTC](https://www.ruby-forum.com/t/ajax-on-rails/147867 "2008-09-06T10:36:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [September 6, 2008, 10:36am UTC](https://www.ruby-forum.com/t/ajax-on-rails/147867/1 "2008-09-06T10:36:47Z")

</div>

I need som help i want tha a hole

 to have a link to remote  
to a  
controllers action (yo do click on any part inside th div and the action  
is  
executed)  
how can i do that!!

–  
Felipe V. Contesse  
IngenierÃ­a Civil Industrial UC

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [September 6, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/ajax-on-rails/147867/2 "2008-09-06T16:15:45Z")

</div>

Felipe V. wrote:

> I need som help i want tha a hole
> 
> to have a link to remote  
> to a controllers action (yo do click on any part inside th div and the  
> action is executed)  
> how can i do that!!

Put everything inside the div into a partial. Put the link\_to\_remote  
around the  
partial, like this:

\<%= link\_to\_remote render(:partial =\> ‘my\_partial’), :url =\> {…} %\>

I suspect you’ll get an with an entire stretch of HTML inside, not  
just a  
string. Report back if the link\_to\_remote calls h() on the HTML!

–  
Phlip

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [September 6, 2008, 5:26pm UTC](https://www.ruby-forum.com/t/ajax-on-rails/147867/3 "2008-09-06T17:26:37Z")

</div>

i will try that thank yo very much!!

On Sat, Sep 6, 2008 at 10:14 AM, Phlip [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> partial, like this:
> 
> >

–  
Felipe V. Contesse  
IngenierÃ­a Civil Industrial UC

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [September 6, 2008, 11:42pm UTC](https://www.ruby-forum.com/t/ajax-on-rails/147867/4 "2008-09-06T23:42:35Z")

</div>

Felipe V. wrote:

> i will try that thank yo very much!!

Oh yeah and test the living crap out of it, preferably with  
assert\_xpath,  
because it’s going to be a major hazard at code upgrade time!

> ```
> <%= link_to_remote render(:partial => 'my_partial'), :url => {...} %>
> ```

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [September 7, 2008, 6:46pm UTC](https://www.ruby-forum.com/t/ajax-on-rails/147867/5 "2008-09-07T18:46:44Z")

</div>

Felipe V. wrote:

> i didnt understant the assert\_xpath
> 
> ```
> > <%= link_to_remote render(:partial => 'my_partial'), :url
> => {...} %>
> 
> ```

When you test that, it will produce an , so capture that. First put a

\<div id='clickable\_div' around the linker. Then capture it like this:

assert\_tag\_id :div, :clickable\_div do  
assert\_xpath ‘a’ do |a|  
assert{ a[:href] == ‘#’ }  
puts indent\_xml  
end  
end

When you run that test, the puts indent\_xml will spew out the contents  
of the  
partial inside the .

Then you can call assert\_tag\_id or assert\_xpath, again, to find some  
detail  
inside the partial.

This way, a change that looks harmless, to the or the partial, has  
greater  
odds of raising a red flag instantly, while testing.

–  
Phlip

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [September 7, 2008, 5:39pm UTC](https://www.ruby-forum.com/t/ajax-on-rails/147867/6 "2008-09-07T17:39:57Z")

</div>

i didnt understant the assert\_xpath

thak you anyway i will check for information!!!

On 9/6/08, Phlip [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> %\>
> 
> > ```
> > --
> > Phlip
> > 
> > ```
> 
> >

–  
Felipe V. Contesse  
IngenierÃ­a Civil Industrial UC

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [September 7, 2008, 10:30pm UTC](https://www.ruby-forum.com/t/ajax-on-rails/147867/7 "2008-09-07T22:30:57Z")

</div>

thank you very much!!

On 9/7/08, Phlip [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> id=‘clickable\_div’ around the linker. Then capture it like this:  
> partial inside the .
> 
>  
> 
> >

 

–  
Felipe V. Contesse  
IngenierÃ­a Civil Industrial UC
