Quick Rails/javascript questions

Hello,

OK, I have several questions, probably trivial:

  • I am running a loop in a controller and if a condition within this
    loop happens to be true i want an action to take place. This action is
    to display a prompt, which involves executing some javascript. So when
    the condition within the loop is true i want to execute some javascript
    from the controller. How do i execute javascript from the controller?

  • I understand that assigning a javascript variable to a ruby one is
    difficult, so is it possible to call a ruby method from my javascript
    code passing in a javascript variable. I am prompting the user for input
    and i would like to use the resulting string (input).

  • Secondly, i have additional classes that i want to include in my rails
    project, where do these go?

answers to any of these questions is very much appreciated.