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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks thorsten. That makes sense. I will just have to bite the bullet and re-write the algorithm in ruby. Thorsten Mueller wrote:> 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-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---