# Rendering partial from button click, not passing locals?

**URL:** <https://www.ruby-forum.com/t/rendering-partial-from-button-click-not-passing-locals/181244>\
**Category:** Rails\
**Created:** [January 7, 2010, 9:52pm UTC](https://www.ruby-forum.com/t/rendering-partial-from-button-click-not-passing-locals/181244 "2010-01-07T21:52:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [January 7, 2010, 9:52pm UTC](https://www.ruby-forum.com/t/rendering-partial-from-button-click-not-passing-locals/181244/1 "2010-01-07T21:52:10Z")

</div>

I wrote the relevant code in this pastie:  
[http://pastie.org/770642](http://pastie.org/770642)  
(it’s not too much code – but it looks a ton better than black on  
white!)

And here is the bit from my log:

Processing UltrasoundsController#index (for 127.0.0.1 at 2010-01-07  
10:32:03) [GET]  
Rendering template within layouts/application  
Rendering ultrasounds/index  
Completed in 172ms (View: 16, DB: 105044) | 200 OK  
[[http://localhost/ultrasounds](http://localhost/ultrasounds)]

Processing UltrasoundsController#fix\_ultrasounds (for 127.0.0.1 at  
2010-01-07 10:32:05) [POST]  
Parameters:  
{“authenticity\_token”=\>“I7ucDb3iTXMpaFeRdCjTGtu6qFSgSq92VBCKg4SIcFA=”}  
Completed in 532ms (View: 0, DB: 0) | 200 OK  
[[http://localhost/ultrasounds/fix\_ultrasounds](http://localhost/ultrasounds/fix_ultrasounds)]

Do you know why “rows” doesn’t get passed, like I would expect it to?

---

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [January 8, 2010, 6:13am UTC](https://www.ruby-forum.com/t/rendering-partial-from-button-click-not-passing-locals/181244/2 "2010-01-08T06:13:32Z")

</div>

best choice is ajax

2010/1/8 Aldric G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [January 8, 2010, 6:29am UTC](https://www.ruby-forum.com/t/rendering-partial-from-button-click-not-passing-locals/181244/3 "2010-01-08T06:29:20Z")

</div>

don’t you need to specify  
%p== #{rows} updated

??

---

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [January 8, 2010, 3:30pm UTC](https://www.ruby-forum.com/t/rendering-partial-from-button-click-not-passing-locals/181244/4 "2010-01-08T15:30:05Z")

</div>

Curtis S. wrote:

> don’t you need to specify  
> %p== #{rows} updated
> 
> ??

According to the HAML reference:  
[http://haml-lang.com/docs/yardoc/file.HAML\_REFERENCE.html#ruby\_interpolation\_](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#ruby_interpolation_)

%p This is #{h quality} cake!

This should work. So I was missing the ‘h’, which I added:  
%p #{h rows} updated.

But … No cigar.

---

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [January 8, 2010, 6:59pm UTC](https://www.ruby-forum.com/t/rendering-partial-from-button-click-not-passing-locals/181244/5 "2010-01-08T18:59:40Z")

</div>

On Fri, Jan 8, 2010 at 9:25 AM, Aldric G.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> %p There were #{h rows} updated.  
> sounds like a good place to start with a test (results.size.should == 1)  
> good luck - ‘ruby-debug’ is on of my favorite tools for stuff like this.

---

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [January 8, 2010, 5:25pm UTC](https://www.ruby-forum.com/t/rendering-partial-from-button-click-not-passing-locals/181244/6 "2010-01-08T17:25:38Z")

</div>

Aldric G. wrote:

> Curtis S. wrote:
> 
> > don’t you need to specify  
> > %p== #{rows} updated
> > 
> > ??

I tried these:  
%p #{h rows} updated.  
%p= "There were #{h rows} updated.  
%p There were #{h rows} updated.  
%p== There were #{h rows} updated.

I always got a “0” where “rows” was interpolated. So … Either the  
variable isn’t passed correctly, or it is, and the result is zero.

Well, I tried to run one of the update queries using the run\_query  
method in irb, and got a result of 5… Which surprised me because the  
result should have been one. So there’s probably a few things going on  
here…
