Calling Javascript From Model

Hello Everyone,

I am pretty new to ROR and am working on my first project which involves
a pretty sophisticated search. Currently I am performing the search in
the model. Now for every record in the db I have to do a complicated
test to see whether or not I should include it in my results. I already
have the code for the test written in javascript and would like to know
three things:

a) Can I call the javascript function from within a function in my
model?
b) If a) is ok how do I do it?
c) Is this bad form? Should I instead re-write the complicated test in
ruby?

Thanks for your input!

this is missing a few details, but anyway:
no, it's not possible, to call any js from the model.
the model will run on the server, the js in the browser...

only way would be ajax (and then you would call it from the view, not
the model)
and this would only make for the purpose to update the browser

without knowledge of details:
any logic that runs on your data to be done in the model
and that means Ruby

Thanks thorsten. That makes sense. I will just have to bite the bullet
and re-write the algorithm in ruby.

Thorsten Mueller wrote: