# Javascript is not working in render\_component

**URL:** <https://www.ruby-forum.com/t/javascript-is-not-working-in-render-component/129802>\
**Category:** Rails\
**Created:** [February 21, 2008, 6:06pm UTC](https://www.ruby-forum.com/t/javascript-is-not-working-in-render-component/129802 "2008-02-21T18:06:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![balavrscse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e4f/32.png) [@balavrscse](https://www.ruby-forum.com/u/balavrscse)\
**Post date:** [February 21, 2008, 6:06pm UTC](https://www.ruby-forum.com/t/javascript-is-not-working-in-render-component/129802/1 "2008-02-21T18:06:46Z")

</div>

Hi,  
I am calling on action using render\_component,in that action i am  
again calling one javacritp function.when i am execute this code the  
script is not working,my code is here.

my view goes here:  
rating :  
\<%=render\_component(:controller=\>‘products’,:action=\>‘star\_display’,:params=\>{:product\_id=\>2})%\>

action is  
def star\_display  
product\_id=params[:product\_id]  
overall\_rating=ProductRating.find  
rating=overall\_Rating  
end

My star\_display view is  
 ![](https://test.ruby-forum.com/images/star1.gif)  
 ![](https://test.ruby-forum.com/images/star1.gif)  
 ![](https://test.ruby-forum.com/images/star1.gif)  
 ![](https://test.ruby-forum.com/images/star1.gif)

here the script is not working.but if i print anything inside of the  
script tag it gets printed means the action executed successfully but  
the script is not running.i don’t know what’s the reason please anybody  
help me.

thanks,  
Bala

---

<div class="post-metadata">

**Author:** ![balavrscse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e4f/32.png) [@balavrscse](https://www.ruby-forum.com/u/balavrscse)\
**Post date:** [February 21, 2008, 6:12pm UTC](https://www.ruby-forum.com/t/javascript-is-not-working-in-render-component/129802/2 "2008-02-21T18:12:58Z")

</div>

On 21 Feb 2008, at 17:06, Bala Krishnan wrote:

> Hi,  
> I am calling on action using render\_component,in that action i am  
> again calling one javacritp function.when i am execute this code the  
> script is not working,my code is here.

You don’t seem to be setting @rating in your action. Have you tried  
using firebug to step through your javascript and see where it is  
failing ?  
(oh and render\_component is deprecated and very rarely the right thing  
to do)

Fred
