Search Results

Search found 1 results on 1 pages for 'emroot'.

Page 1/1 | 1 

  • Prime Number - Data while loading

    - by Emroot
    Hi, I was trying in Ruby on Rails how to find a prime number. Here is my code : helper : app/helpers/test_helper.rb module TestHelper def prime_number? number index = 2 tmp = 0 while index <= number if tmp < 1 if (number % index) == 0 tmp += 1 end else return false end index += 1 end return true end end and my view : app/views/test/index.html.erb <% (2..100).each do |i| -%> <% if prime_number? i %> <%= i %> <% end -%> <% end -%> So my question is : How can you load data while it's calculating ? I mean if I replace 100 by 100000 in my view, how can I see data on my view while my helper method is calculating ? Do I need to use ajax or rails provide a tool for that ? Thank you.

    Read the article

1