0

I'm new to programming and rails so please forgive any big oversights. I recently deployed a rails app to heroku and switched all environments to postgres for my db. It is up on heroku working just fine with Postgres - ran rake db:drop db:migrate db:create db:seed all to populate my database with a rake task, tested the apps search forms, filters, data queries, etc. and it all worked well.

But I am now getting an error that says "comparison of ActiveSupport::SafeBuffer with nil failed" in the browser after firing up my local server and going to two of my views that have sorts - the browser is pointing me to a line in a view that has

<% @price_array.sort! {|x,y| x <=> y} %>

This is what I see in the server log:

Rendered skis/index.html.erb within layouts/application (212.9ms)
Completed 500 Internal Server Error in 280ms

ActionView::Template::Error (comparison of ActiveSupport::SafeBuffer with nil failed):
51:                     <% ski.inventories.each do |inventory| %>
52:                         <% a.push(number_to_currency(inventory.price)) %>
53:                         <% end %>
54:                         <% @lowest_price = a.sort { |x,y| x <=> y} %>
55:                         from <%= @lowest_price.first %>
56:                     </br>
57:                 </li>
app/views/skis/index.html.erb:54:in `sort'
app/views/skis/index.html.erb:54:in `block in_app_views_skis_index_html_erb___2303745325449705978_70146899313600'
app/views/skis/index.html.erb:32:in `each'
app/views/skis/index.html.erb:32:in `_app_views_skis_index_html_erb___2303745325449705978_70146899313600'
app/controllers/skis_controller.rb:32:in `index'

This may be related to the issue I am in running into - I cannot seem to drop my postgres database.

This is what I'm seeing in the terminal with postgres:

postgres=# \dbdrop postgres
List of tablespaces
Name | Owner | Location 
------+-------+----------
(0 rows)

One other thing I did last night was update my .bash_profile per the instructions found here (http://stackoverflow.com/questions/6770649/repairing-postgresql-after-upgrading-to-osx-10-7-lion). This is what my .bash_profile looks like now:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

PATH=/usr/local/bin:$PATH

Is there some configuration in postgres that I am missing that is causing this error? Any help or resources would be appreciated. Thanks.

pvskisteak5
  • 4,162
  • 3
  • 24
  • 26

1 Answers1

0

you have nil values in your a array. Try :

 a.compact.sort

compact removes all occurences of nil in your array.

m_x
  • 12,357
  • 7
  • 46
  • 60
  • Thanks - that did the trick. Curious why it worked for while, must be getting a nil in the data I'm aggregating where I was not before. Thanks again. – pvskisteak5 Dec 05 '12 at 17:07