LocalJumpError (Ruby on Rails) -


I have searched / surrounded by Google but I am battling the following problem.

I am building a Rail 2.3.2 application and one of the requirements to calculate the middle of an array of results. I am using code to calculate median from Ruby cookbook, but when I try to find between an array where there is a strange number of members' receiving a local error 'error' The problem persists in / P>

The example code in my view is as follows:

  & lt;% = survey_progress Media ([6,4,5,4,4,2])%>  

Then the methods in the survey_response.rb model are as follows:

  def means (array) array.inject (array.inject (0) {| Sum, X | sum + = x} / array.size.to_f) End DRD intermediate (array, already exists = false) return zero if array.empty? Array = array.sort until the first_sorted m_pos = array.size / 2 returns array. Size% 2 == 1? Array [m_pause]: Meaning (array [m_pose-1m_page])  

The error occurs when the mean method refers back to the method so that the total item in the array of media in the weird array I can not understand why I get this error or actually have to fix it - so I can encourage any help / guidance / laughing at someone! >

LIS looks like this is done by using the Flexional index in your operation. Try changing:

  with m_pos = array.size / 2  

:

m_pos = (array.size / 2).

Also, try to change its mean function:

  def mean (array) array.inject (0) {| Sum, x | Sum + = x} / array.size.to_f End  

Comments