The application runs perfectly in development(local server) but not in production.
I have the following in heroku logs(I have edited the logs to be easier to read, I just included what I think are the errors):
2015-05-15T23:58:43.894626+00:00 app[web.1]: Rendered layouts/_header.html.erb (8.5ms)
2015-05-15T23:58:43.885011+00:00 app[web.1]: Rendered movies/index.html.erb within layouts/application (17.5ms)
2015-05-15T23:58:43.896788+00:00 app[web.1]: ActionView::Template::Error (undefined method `scard' for nil:NilClass):
2015-05-15T23:58:43.896785+00:00 app[web.1]:
2015-05-15T23:58:43.896790+00:00 app[web.1]: 19: <%if signed_in?%>
2015-05-15T23:58:43.896791+00:00 app[web.1]: 20: <li>
2015-05-15T23:58:43.896794+00:00 app[web.1]: 22: <i class="fi-shopping-cart"></i> My Cart (<span class="cart-count"><%=current_user.cart_count%></span>)
2015-05-15T23:58:43.896793+00:00 app[web.1]: 21: <%= link_to cart_path do%>
2015-05-15T23:58:43.896796+00:00 app[web.1]: 23: <%end%>
2015-05-15T23:58:43.896797+00:00 app[web.1]: 24: </li>
2015-05-15T23:58:43.896799+00:00 app[web.1]: 25: <li><%=link_to current_user.email, edit_user_registration_path%></li>
2015-05-15T23:58:43.896801+00:00 app[web.1]: app/models/user.rb:36:in `cart_count'
2015-05-15T23:58:33.939033+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2015-05-15T23:58:33.933343+00:00 app[web.1]: Started GET "/movies/2" for 160.9.1.112 at 2015-05-15 23:58:33 +0000
2015-05-15T23:58:33.935944+00:00 app[web.1]: Processing by MoviesController#show as HTML
2015-05-15T23:58:33.935966+00:00 app[web.1]: Parameters: {"id"=>"2"}
2015-05-15T23:58:33.938157+00:00 app[web.1]: Movie Load (1.3ms) SELECT "movies".* FROM "movies" WHERE "movies"."id" = $1 LIMIT 1 [["id", 2]]
2015-05-15T23:58:33.939854+00:00 app[web.1]:
2015-05-15T23:58:33.939856+00:00 app[web.1]: NoMethodError (undefined method `sismember' for nil:NilClass):
2015-05-15T23:58:33.939858+00:00 app[web.1]: app/models/movie.rb:20:in `cart_action'
2015-05-15T23:58:33.939859+00:00 app[web.1]: app/controllers/movies_controller.rb:9:in `show'
2015-05-15T23:58:28.575297+00:00 app[web.1]: Started GET "/movies/1" for 160.9.1.112 at 2015-05-15 23:58:28 +0000
2015-05-15T23:58:28.581745+00:00 app[web.1]: Parameters: {"id"=>"1"}
2015-05-15T23:58:28.635038+00:00 app[web.1]: Completed 500 Internal Server Error in 53ms
2015-05-15T23:58:28.581412+00:00 app[web.1]: Processing by MoviesController#show as HTML
2015-05-15T23:58:28.618562+00:00 app[web.1]: Movie Load (1.6ms) SELECT "movies".* FROM "movies" WHERE "movies"."id" = $1 LIMIT 1 [["id", 1]]
2015-05-15T23:58:28.636023+00:00 app[web.1]:
2015-05-15T23:58:28.636027+00:00 app[web.1]: NoMethodError (undefined method `sismember' for nil:NilClass):
2015-05-15T23:58:28.636029+00:00 app[web.1]: app/models/movie.rb:20:in `cart_action'
2015-05-15T23:58:28.636031+00:00 app[web.1]: app/controllers/movies_controller.rb:9:in `show'
movie.rb:
class Movie < ActiveRecord::Base
has_many :purchases
has_many :buyers, through: :purchases
before_save :embed_video_url
def poster
"http://ia.media-imdb.com/images/M/#{poster_url}"
end
def imdb
"http://www.imdb.com/title/#{imdb_id}/"
end
def embed_video_url
self.video_url = "//www.youtube.com/embed/#{video_url.split('v=')[1].split('&list')[0]}"
end
def cart_action(current_user_id)
if $redis.sismember "cart#{current_user_id}", id
"Remove from"
else
"Add to"
end
end
end
I followed the official guide from heroku "https://devcenter.heroku.com/articles/redistogo"
Even the test run ok but cant run in production
I know it's exhausting to check all these line so I will appreciate any help
PS: In development/local server run perfect
The error is appearing in the logs. See carefully.
NoMethod Error (undefined method sismember' for nil:NilClass): 2015-05 15T20:59:10.873219+00:00 app[web.1]: app/models/movie.rb:20:incart_action'
Related
I've been having a little issue with one of the apps I deployed to Heroku. Locally the app works fine, however on Heroku when I press a button that illicits an Ajax request I get a 500 error. The error is more specifically coming from a method within my controller called adding. Below are the logs from Heroku. Link to app: https://ouinyc.herokuapp.com/
**p.s to see the button that's giving the error you have to sign up, it's the two buttons below the stop and play buttons. **
Curiously this is the error that stands out the most.
NoMethodError (undefined method `delete!' for nil:NilClass):
app/controllers/static_pages_controller.rb:27:in `add_song'
Below are some of the logs from Heroku
2016-04-25T22:28:09.603876+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'
2016-04-25T22:28:09.603878+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
2016-04-25T22:28:09.603874+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
2016-04-25T22:28:09.603875+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/engine.rb:518:in `call'
2016-04-25T22:28:09.603879+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
2016-04-25T22:28:09.603877+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'
2016-04-25T22:28:09.603878+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:88:in `service'
2016-04-25T22:28:09.603880+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
2016-04-25T22:28:09.603881+00:00 app[web.1]:
2016-04-25T22:28:09.603881+00:00 app[web.1]:
2016-04-25T22:28:11.095771+00:00 app[web.1]: Rendered layouts/_shim.html.erb (0.4ms)
2016-04-25T22:28:11.133322+00:00 app[web.1]: Rendered layouts/_audio_part.html.erb (7.2ms)
2016-04-25T22:28:11.133624+00:00 app[web.1]: Completed 200 OK in 50ms (Views: 45.6ms | ActiveRecord: 3.8ms)
2016-04-25T22:28:11.107578+00:00 app[web.1]: Rendered layouts/_header.html.erb (7.9ms)
2016-04-25T22:28:11.105471+00:00 app[web.1]: User Load (3.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
2016-04-25T22:28:11.120143+00:00 app[web.1]: Rendered layouts/_footer.html.erb (2.8ms)
2016-04-25T22:28:11.090234+00:00 app[web.1]: Rendered static_pages/home.html.erb within layouts/application (0.6ms)
2016-04-25T22:28:11.081117+00:00 app[web.1]: Started GET "/home" for 98.14.169.85 at 2016-04-25 22:28:11 +0000
2016-04-25T22:28:11.083194+00:00 app[web.1]: Processing by StaticPagesController#home as HTML
2016-04-25T22:28:11.135758+00:00 heroku[router]: at=info method=GET path="/home" host=ouinyc.herokuapp.com request_id=2be011c5-bff4-4ac6-8c0b-a681f7826f32 fwd="98.14.169.85" dyno=web.1 connect=0ms service=63ms status=200 bytes=7100
2016-04-25T22:28:23.338889+00:00 heroku[router]: at=info method=GET path="/90210%20by%20Travis%20Scott.mp3" host=ouinyc.herokuapp.com request_id=b8770d58-15e2-40d9-a002-8ddd4fb9d4db fwd="98.14.169.85" dyno=web.1 connect=0ms service=166ms status=206 bytes=8526220
2016-04-25T22:28:41.387156+00:00 heroku[router]: at=info method=POST path="/adding" host=ouinyc.herokuapp.com request_id=5c6bd67b-2c43-4086-90ff-b0fd0f524cd9 fwd="98.14.169.85" dyno=web.1 connect=0ms service=58ms status=500 bytes=1754
2016-04-25T22:28:41.375423+00:00 app[web.1]: Started POST "/adding" for 98.14.169.85 at 2016-04-25 22:28:41 +0000
2016-04-25T22:28:41.377153+00:00 app[web.1]: Processing by StaticPagesController#add_song as */*
2016-04-25T22:28:41.377249+00:00 app[web.1]: Parameters: {"data_value"=>"\"https://ouinyc.herokuapp.com/90210%20by%20Travis%20Scott.mp3\"", "authenticity_token"=>""}
2016-04-25T22:28:41.379928+00:00 app[web.1]: User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
2016-04-25T22:28:41.381122+00:00 app[web.1]: User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-04-25T22:28:41.382269+00:00 app[web.1]: Completed 500 Internal Server Error in 5ms (ActiveRecord: 1.0ms)
2016-04-25T22:28:41.385136+00:00 app[web.1]:
2016-04-25T22:28:41.385145+00:00 app[web.1]: NoMethodError (undefined method `delete!' for nil:NilClass):
2016-04-25T22:28:41.385146+00:00 app[web.1]: app/controllers/static_pages_controller.rb:27:in `add_song'
2016-04-25T22:28:41.385147+00:00 app[web.1]:
edit
So the issue looks like it has to deal with the controller. That said I don't understand why it's saying the string object is empty.
Controller
class StaticPagesController < ApplicationController
respond_to :js, :json, :html
def get_songs()
if user_signed_in?
session[:user_id] = current_user.id
present_user = User.find(session[:user_id])
present_user = present_user.playlist.keys
#songs = present_user
respond_to do |format|
format.json { render :json => #songs}
end
end
end
def add_song()
if user_signed_in?
session[:user_id] = current_user.id
present_user = User.find(session[:user_id])
var = params[:data_value]
var = var.sub!("http://localhost:3000/", "")
var.delete!('""','')
present_user.playlist.store(var, 1)
if present_user.save
render json: {success: "It works"}
end
end
end
def remove_song()
if user_signed_in?
session[:user_id] = current_user.id
present_user = User.find(session[:user_id])
var = params[:data_value]
present_user.playlist.delete(var)
if present_user.save
render json: {success: "It works"}
end
end
end
def news
end
def home
end
end
ajax request
$.ajax({
url: "removing",
type: "post",
data: {data_value: JSON.stringify(player.src), authenticity_token: "<%= #form_auth_token %>" }
}
);
Well, the problem code is the following, please dont' used without a real reason non-pure methods with !. And this line evaluated var to nil, since previous value of var has no prefixed line:
var = var.sub!("http://localhost:3000/", "")
so next var.delete! riases the exception:
Well the part of code:
var = params[:data_value]
var = var.sub!("http://localhost:3000/", "")
var.delete!('""','')
present_user.playlist.store(var, 1)
can be replaced with (since you are passing JSON encoded value):
song = JSON.parse((params[:data_value]).sub("localhost:3000/", ""),
{:quirks_mode => true})'
present_user.playlist.store(song, 1)
I am having trouble getting my Heroku app running. I want to import some data to my heroku database. I did this by running:
heroku pg:psql
\copy tablename FROM 'db/tableInfo.csv' DELIMITER ',' CSV;
then when I run:
select* from tablename
It prints out all the data I uploaded from the CSV, as desired.
However, when I go to my app and run "heroku open" my browser shows a page that says "We're sorry, but something went wrong." Then when I check the heroku logs, it says "PG::UndefinedTable: ERROR: relation "tablename" does not exist"
I am confused because when I go to the heroku site it says there are 3 rows (which I uploaded to tablename) and the "select * from tablename" after running heroku pg:psql displayed all the data that I wanted. Does anyone know why the relation isn't being recognized?
Thanks!
After running db:migrate I get this issue
EDIT: Here is the output from heroku logs (experimentInfo is the table name)
2016-03-15T05:33:16.813191+00:00 app[web.1]: LINE 1: SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expI...
2016-03-15T05:33:16.813192+00:00 app[web.1]: ^
2016-03-15T05:33:16.813193+00:00 app[web.1]: : SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expId != 'expId')
2016-03-15T05:33:16.813801+00:00 app[web.1]: Rendered main/experimentHome.html.erb within layouts/application (2.6ms)
2016-03-15T05:33:16.813872+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms
2016-03-15T05:33:16.816093+00:00 app[web.1]:
2016-03-15T05:33:16.816105+00:00 app[web.1]: ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "experimentInfo" does not exist
2016-03-15T05:33:16.816123+00:00 app[web.1]: LINE 1: SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expI...
2016-03-15T05:33:16.816124+00:00 app[web.1]: ^
2016-03-15T05:33:16.816126+00:00 app[web.1]: 7: <%= #mexpMessage %>
2016-03-15T05:33:16.816125+00:00 app[web.1]: : SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expId != 'expId')):
2016-03-15T05:33:16.816127+00:00 app[web.1]: 8: <div class="alert alert-warning" style = "color:black" align = "left"><%= "To begin browsing the database, click on one of the experiments listed below. You can find information about each experiment listed in the blue boxes below each experiment link. To download the raw data for a given experiment, click the link next to the 'Click to download' field." %></div>
2016-03-15T05:33:16.816128+00:00 app[web.1]: 9: <h4> List of Experiments: </h4>
2016-03-15T05:33:16.816128+00:00 app[web.1]: 10: <% #experimentList.each do |e| %>
2016-03-15T05:33:16.816130+00:00 app[web.1]: 12: </a>
2016-03-15T05:33:16.816129+00:00 app[web.1]: 11: <%= link_to e.title, search_path(:selectexp => e.expId) %>
2016-03-15T05:33:16.816131+00:00 app[web.1]: 13: <div class="alert alert-info">
2016-03-15T05:33:16.816132+00:00 app[web.1]: app/views/main/experimentHome.html.erb:10:in `block in _app_views_main_experiment_ome_html_erb___1511755932124521423_70162519516940'
2016-03-15T05:33:16.816133+00:00 app[web.1]: app/views/main/experimentHome.html.erb:1:in `_app_views_main_experiment_ome_html_erb___1511755932124521423_70162519516940'
2016-03-15T05:33:16.816134+00:00 app[web.1]: app/controllers/main_controller.rb:6:in `experimentHome'
2016-03-15T05:33:16.816135+00:00 app[web.1]:
2016-03-15T05:33:16.816135+00:00 app[web.1]:
2016-03-15T05:33:16.805861+00:00 heroku[router]: at=info method=GET path="/" host=sheltered-beach-44318.herokuapp.com request_id=9b7cfa64-a230-4077-b676-96f407bda79a fwd="128.12.253.5" dyno=web.1 connect=1ms service=34ms status=500 bytes=1458
2016-03-15T05:38:27.339628+00:00 heroku[router]: at=info method=GET path="/" host=sheltered-beach-44318.herokuapp.com request_id=3a672911-5097-46ba-8920-7a307caeef2e fwd="128.12.253.5" dyno=web.1 connect=1ms service=32ms status=500 bytes=1458
2016-03-15T05:38:27.321501+00:00 app[web.1]: Started GET "/" for 128.12.253.5 at 2016-03-15 05:38:27 +0000
2016-03-15T05:38:27.343748+00:00 app[web.1]: Processing by MainController#experimentHome as HTML
2016-03-15T05:38:27.347286+00:00 app[web.1]: PG::UndefinedTable: ERROR: relation "experimentInfo" does not exist
2016-03-15T05:38:27.347296+00:00 app[web.1]: LINE 1: SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expI...
2016-03-15T05:38:27.347298+00:00 app[web.1]: ^
2016-03-15T05:38:27.347299+00:00 app[web.1]: : SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expId != 'expId')
2016-03-15T05:38:27.348006+00:00 app[web.1]: Rendered main/experimentHome.html.erb within layouts/application (3.7ms)
2016-03-15T05:38:27.348212+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms
2016-03-15T05:38:27.350701+00:00 app[web.1]:
2016-03-15T05:38:27.350712+00:00 app[web.1]: ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "experimentInfo" does not exist
2016-03-15T05:38:27.350712+00:00 app[web.1]: LINE 1: SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expI...
2016-03-15T05:38:27.350713+00:00 app[web.1]: ^
2016-03-15T05:38:27.350714+00:00 app[web.1]: : SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expId != 'expId')):
2016-03-15T05:38:27.350716+00:00 app[web.1]: 7: <%= #mexpMessage %>
2016-03-15T05:38:27.350718+00:00 app[web.1]: 8: <div class="alert alert-warning" style = "color:black" align = "left"><%= "To begin browsing the database, click on one of the experiments listed below. You can find information about each experiment listed in the blue boxes below each experiment link. To download the raw data for a given experiment, click the link next to the 'Click to download' field." %></div>
2016-03-15T05:38:27.350719+00:00 app[web.1]: 10: <% #experimentList.each do |e| %>
2016-03-15T05:38:27.350718+00:00 app[web.1]: 9: <h4> List of Experiments: </h4>
2016-03-15T05:38:27.350720+00:00 app[web.1]: 11: <%= link_to e.title, search_path(:selectexp => e.expId) %>
2016-03-15T05:38:27.350720+00:00 app[web.1]: 12: </a>
2016-03-15T05:38:27.350721+00:00 app[web.1]: 13: <div class="alert alert-info">
2016-03-15T05:38:27.350722+00:00 app[web.1]: app/views/main/experimentHome.html.erb:10:in `block in _app_views_main_experiment_ome_html_erb___1511755932124521423_70162519291600'
2016-03-15T05:38:27.350724+00:00 app[web.1]: app/views/main/experimentHome.html.erb:1:in `_app_views_main_experiment_ome_html_erb___1511755932124521423_70162519291600'
2016-03-15T05:38:27.350725+00:00 app[web.1]: app/controllers/main_controller.rb:6:in `experimentHome'
2016-03-15T05:38:27.350725+00:00 app[web.1]:
2016-03-15T05:38:27.350726+00:00 app[web.1]:
2016-03-15T05:49:37.158759+00:00 heroku[router]: at=info method=GET path="/" host=sheltered-beach-44318.herokuapp.com request_id=fe636ea4-c661-4ca3-b5b9-3b8e809f9a42 fwd="128.12.253.5" dyno=web.1 connect=2ms service=14ms status=500 bytes=1458
2016-03-15T05:49:37.157464+00:00 app[web.1]: Started GET "/" for 128.12.253.5 at 2016-03-15 05:49:37 +0000
2016-03-15T05:49:37.158827+00:00 app[web.1]: Processing by MainController#experimentHome as HTML
2016-03-15T05:49:37.162467+00:00 app[web.1]: PG::UndefinedTable: ERROR: relation "experimentInfo" does not exist
2016-03-15T05:49:37.162475+00:00 app[web.1]: LINE 1: SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expI...
2016-03-15T05:49:37.162477+00:00 app[web.1]: ^
2016-03-15T05:49:37.162478+00:00 app[web.1]: : SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expId != 'expId')
2016-03-15T05:49:37.163383+00:00 app[web.1]: Rendered main/experimentHome.html.erb within layouts/application (3.6ms)
2016-03-15T05:49:37.163562+00:00 app[web.1]: Completed 500 Internal Server Error in 5ms
2016-03-15T05:49:37.166125+00:00 app[web.1]:
2016-03-15T05:49:37.166138+00:00 app[web.1]: ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "experimentInfo" does not exist
2016-03-15T05:49:37.166139+00:00 app[web.1]: LINE 1: SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expI...
2016-03-15T05:49:37.166139+00:00 app[web.1]: ^
2016-03-15T05:49:37.166140+00:00 app[web.1]: : SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expId != 'expId')):
2016-03-15T05:49:37.166141+00:00 app[web.1]: 7: <%= #mexpMessage %>
2016-03-15T05:49:37.166144+00:00 app[web.1]: 9: <h4> List of Experiments: </h4>
2016-03-15T05:49:37.166160+00:00 app[web.1]: 10: <% #experimentList.each do |e| %>
2016-03-15T05:49:37.166161+00:00 app[web.1]: 11: <%= link_to e.title, search_path(:selectexp => e.expId) %>
2016-03-15T05:49:37.166161+00:00 app[web.1]: 12: </a>
2016-03-15T05:49:37.166144+00:00 app[web.1]: 8: <div class="alert alert-warning" style = "color:black" align = "left"><%= "To begin browsing the database, click on one of the experiments listed below. You can find information about each experiment listed in the blue boxes below each experiment link. To download the raw data for a given experiment, click the link next to the 'Click to download' field." %></div>
2016-03-15T05:49:37.166162+00:00 app[web.1]: 13: <div class="alert alert-info">
2016-03-15T05:49:37.166163+00:00 app[web.1]: app/views/main/experimentHome.html.erb:10:in `block in _app_views_main_experiment_ome_html_erb___1511755932124521423_70162519291600'
2016-03-15T05:49:37.166164+00:00 app[web.1]: app/views/main/experimentHome.html.erb:1:in `_app_views_main_experiment_ome_html_erb___1511755932124521423_70162519291600'
2016-03-15T05:49:37.166165+00:00 app[web.1]: app/controllers/main_controller.rb:6:in `experimentHome'
2016-03-15T05:49:37.166166+00:00 app[web.1]:
2016-03-15T05:49:37.166166+00:00 app[web.1]:
2016-03-15T05:51:40.692387+00:00 heroku[router]: at=info method=GET path="/" host=sheltered-beach-44318.herokuapp.com request_id=4867e943-7dab-40d9-8944-a030c8977e39 fwd="128.12.253.5" dyno=web.1 connect=0ms service=12ms status=500 bytes=1458
2016-03-15T05:51:40.699721+00:00 app[web.1]: Started GET "/" for 128.12.253.5 at 2016-03-15 05:51:40 +0000
2016-03-15T05:51:40.700884+00:00 app[web.1]: Processing by MainController#experimentHome as HTML
2016-03-15T05:51:40.706934+00:00 app[web.1]: PG::UndefinedTable: ERROR: relation "experimentInfo" does not exist
2016-03-15T05:51:40.706951+00:00 app[web.1]: ^
2016-03-15T05:51:40.706942+00:00 app[web.1]: LINE 1: SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expI...
2016-03-15T05:51:40.707848+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms
2016-03-15T05:51:40.706953+00:00 app[web.1]: : SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expId != 'expId')
2016-03-15T05:51:40.710357+00:00 app[web.1]:
2016-03-15T05:51:40.707677+00:00 app[web.1]: Rendered main/experimentHome.html.erb within layouts/application (6.0ms)
2016-03-15T05:51:40.710386+00:00 app[web.1]: ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "experimentInfo" does not exist
2016-03-15T05:51:40.710387+00:00 app[web.1]: LINE 1: SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expI...
2016-03-15T05:51:40.710388+00:00 app[web.1]: ^
2016-03-15T05:51:40.710388+00:00 app[web.1]: : SELECT "experimentInfo".* FROM "experimentInfo" WHERE (expId != 'expId')):
2016-03-15T05:51:40.710389+00:00 app[web.1]: 7: <%= #mexpMessage %>
2016-03-15T05:51:40.710391+00:00 app[web.1]: 8: <div class="alert alert-warning" style = "color:black" align = "left"><%= "To begin browsing the database, click on one of the experiments listed below. You can find information about each experiment listed in the blue boxes below each experiment link. To download the raw data for a given experiment, click the link next to the 'Click to download' field." %></div>
2016-03-15T05:51:40.710392+00:00 app[web.1]: 9: <h4> List of Experiments: </h4>
2016-03-15T05:51:40.710393+00:00 app[web.1]: 10: <% #experimentList.each do |e| %>
2016-03-15T05:51:40.710393+00:00 app[web.1]: 11: <%= link_to e.title, search_path(:selectexp => e.expId) %>
2016-03-15T05:51:40.710394+00:00 app[web.1]: 12: </a>
2016-03-15T05:51:40.710395+00:00 app[web.1]: 13: <div class="alert alert-info">
2016-03-15T05:51:40.710396+00:00 app[web.1]: app/views/main/experimentHome.html.erb:10:in `block in _app_views_main_experiment_ome_html_erb___1511755932124521423_70162519516940'
2016-03-15T05:51:40.710397+00:00 app[web.1]: app/views/main/experimentHome.html.erb:1:in `_app_views_main_experiment_ome_html_erb___1511755932124521423_70162519516940'
2016-03-15T05:51:40.710399+00:00 app[web.1]:
2016-03-15T05:51:40.710398+00:00 app[web.1]: app/controllers/main_controller.rb:6:in `experimentHome'
2016-03-15T05:51:40.710400+00:00 app[web.1]:
>----< means has_many_and_belongs_to in this post.
Let me start with the model and relationships:
events >-----< categories , events >-----< domains , events >-----< eligibles
I am sorting out the event data in a refresh_controller based on the selection made. Here is the code i'm using. It works perfectly fine with sqlite3. While in production, PG is causing some issues. When I have categories that are not linked to events and do a search it's throwing an error. Let me know if there is another way to do it.
Here is the controller.
def index
#cat = Category.find(params[:category][:category_id]) if params[:category][:category_id].present?
#dom = Domain.find(params[:domain][:domain_id]) if params[:domain][:domain_id].present?
#eli = Eligible.find(params[:eligible][:eligible_id]) if params[:eligible][:eligible_id].present?
#e_1=[]
#e_2=[]
#e_3=[]
#e_1 << #cat.events.collect{|p| p.id} if #cat.present?
#e_2 << #dom.events.collect{|p| p.id} if #dom.present?
#e_3 << #eli.events.collect{|p| p.id} if #eli.present?
#e_f = #e_1 | #e_2 | #e_3
#all = Event.where(id: #e_f)
#user = current_user || User.new
##event_ids || #events.collect{|p| p.id}
##event_ids = id_array.collect{|id| id.to_i}
end
index.html.erb:
<div class="container">
<b> <%= #cat.name if #cat.present? %> <%= #dom.name if #dom.present? %> <%= #eli.name if #eli.present? %></b>
<%= render partial: "static_pages/event", collection: #all %>
</div>
Here are my heroku logs:
heroku logs
2014-03-12T09:39:28.894581+00:00 app[web.1]: /app/vendor/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:170:in `select'
2014-03-12T09:39:28.894581+00:00 app[web.1]: [2014-03-12 09:39:28] FATAL SignalException: SIGTERM
2014-03-12T09:39:28.894581+00:00 app[web.1]: /app/vendor/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:160:in `start'
2014-03-12T09:39:28.894581+00:00 app[web.1]: /app/vendor/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:170:in `block in start'
2014-03-12T09:39:28.894581+00:00 app[web.1]: /app/vendor/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:32:in `start'
2014-03-12T09:39:28.894581+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in `run'
2014-03-12T09:39:28.894834+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
2014-03-12T09:39:28.894834+00:00 app[web.1]: bin/rails:4:in `require'
2014-03-12T09:39:28.894834+00:00 app[web.1]: bin/rails:4:in `<main>'
2014-03-12T09:39:30.273961+00:00 heroku[web.1]: Process exited with status 143
2014-03-12T09:39:33.095928+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 5234 -e production`
2014-03-12T09:39:38.514112+00:00 app[web.1]: [2014-03-12 09:39:38] INFO WEBrick 1.3.1
2014-03-12T09:39:38.514112+00:00 app[web.1]: [2014-03-12 09:39:38] INFO ruby 2.1.0 (2013-12-25) [x86_64-linux]
2014-03-12T09:39:38.514323+00:00 app[web.1]: [2014-03-12 09:39:38] INFO WEBrick::HTTPServer#start: pid=2 port=5234
2014-03-12T09:39:41.211555+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2014-03-12T09:39:41.702711+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
2014-03-12T09:39:41.702711+00:00 app[web.1]: [2014-03-12 09:39:41] FATAL SignalException: SIGTERM
2014-03-12T09:39:41.702711+00:00 app[web.1]: /app/vendor/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:170:in `select'
2014-03-12T09:39:41.702711+00:00 app[web.1]: /app/vendor/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:32:in `start'
2014-03-12T09:39:41.702711+00:00 app[web.1]: /app/vendor/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:170:in `block in start'
2014-03-12T09:39:41.702711+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in `run'
2014-03-12T09:39:41.702711+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands/server.rb:84:in `start'
2014-03-12T09:39:41.702976+00:00 app[web.1]: [2014-03-12 09:39:41] INFO going to shutdown ...
2014-03-12T09:39:41.702711+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
2014-03-12T09:39:41.702976+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
2014-03-12T09:39:41.702976+00:00 app[web.1]: bin/rails:4:in `require'
2014-03-12T09:39:41.702976+00:00 app[web.1]: bin/rails:4:in `<main>'
2014-03-12T09:39:41.702711+00:00 app[web.1]: /app/vendor/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:160:in `start'
2014-03-12T09:39:41.702711+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
2014-03-12T09:39:41.702976+00:00 app[web.1]: => Rails 4.0.2 application starting in production on http://0.0.0.0:5234
2014-03-12T09:39:41.702976+00:00 app[web.1]: => Run `rails server -h` for more startup options
2014-03-12T09:39:41.702976+00:00 app[web.1]: => Booting WEBrick
2014-03-12T09:39:41.702976+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-03-12T09:39:41.702976+00:00 app[web.1]: Exiting
2014-03-12T09:39:41.702976+00:00 app[web.1]: [2014-03-12 09:39:41] INFO WEBrick::HTTPServer#start done.
2014-03-12T09:39:42.930276+00:00 heroku[web.1]: Process exited with status 143
2014-03-12T09:39:51.611779+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 53475 -e production`
2014-03-12T09:39:58.904726+00:00 app[web.1]: [2014-03-12 09:39:58] INFO WEBrick 1.3.1
2014-03-12T09:39:58.904726+00:00 app[web.1]: [2014-03-12 09:39:58] INFO ruby 2.1.0 (2013-12-25) [x86_64-linux]
2014-03-12T09:39:58.904963+00:00 app[web.1]: [2014-03-12 09:39:58] INFO WEBrick::HTTPServer#start: pid=2 port=53475
2014-03-12T09:39:59.295118+00:00 heroku[web.1]: State changed from starting to up
2014-03-12T09:40:00.368665+00:00 app[web.1]: => Run `rails server -h` for more startup options
2014-03-12T09:40:00.368665+00:00 app[web.1]: Started GET "/refresh?utf8=%E2%9C%93&category%5Bcategory_id%5D=&domain%5Bdomain_id%5D=&eligible%5Beligible_id%5D=4&commit=Search" for 122.167.180.66 at 2014-03-12 09:40:00 +0000
2014-03-12T09:40:00.368665+00:00 app[web.1]: => Booting WEBrick
2014-03-12T09:40:00.368665+00:00 app[web.1]: => Rails 4.0.2 application starting in production on http://0.0.0.0:53475
2014-03-12T09:40:00.368665+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-03-12T09:40:00.368665+00:00 app[web.1]: Started GET "/refresh?utf8=%E2%9C%93&category%5Bcategory_id%5D=&domain%5Bdomain_id%5D=&eligible%5Beligible_id%5D=4&commit=Search" for 122.167.180.66 at 2014-03-12 09:40:00 +0000
2014-03-12T09:40:00.493767+00:00 app[web.1]: Processing by RefreshController#index as HTML
2014-03-12T09:40:00.493767+00:00 app[web.1]: Processing by RefreshController#index as HTML
2014-03-12T09:40:00.531632+00:00 app[web.1]: User Load (2.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
2014-03-12T09:40:00.565344+00:00 app[web.1]: Eligible Load (3.0ms) SELECT "eligibles".* FROM "eligibles" WHERE "eligibles"."id" = $1 LIMIT 1 [["id", "4"]]
2014-03-12T09:40:00.493974+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "category"=>{"category_id"=>""}, "domain"=>{"domain_id"=>""}, "eligible"=>{"eligible_id"=>"4"}, "commit"=>"Search"}
2014-03-12T09:40:00.493974+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "category"=>{"category_id"=>""}, "domain"=>{"domain_id"=>""}, "eligible"=>{"eligible_id"=>"4"}, "commit"=>"Search"}
2014-03-12T09:40:00.531632+00:00 app[web.1]: User Load (2.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
2014-03-12T09:40:00.565344+00:00 app[web.1]: Eligible Load (3.0ms) SELECT "eligibles".* FROM "eligibles" WHERE "eligibles"."id" = $1 LIMIT 1 [["id", "4"]]
2014-03-12T09:40:00.599548+00:00 app[web.1]: Event Load (1.6ms) SELECT "events".* FROM "events" WHERE "events"."id" IN ()
2014-03-12T09:40:00.592159+00:00 app[web.1]: Event Load (5.2ms) SELECT "events".* FROM "events" INNER JOIN "eligibles_events" ON "events"."id" = "eligibles_events"."event_id" WHERE "eligibles_events"."eligible_id" = $1 [["eligible_id", 4]]
2014-03-12T09:40:00.599548+00:00 app[web.1]: Event Load (1.6ms) SELECT "events".* FROM "events" WHERE "events"."id" IN ()
2014-03-12T09:40:00.599548+00:00 app[web.1]: LINE 1: SELECT "events".* FROM "events" WHERE "events"."id" IN ()
2014-03-12T09:40:00.599548+00:00 a
pp[web.1]: : SELECT "events".* FROM "events" WHERE "events"."id" IN ()
2014-03-12T09:40:00.599548+00:00 app[web.1]: ^
2014-03-12T09:40:00.599548+00:00 app[web.1]: : SELECT "events".* FROM "events" WHERE "events"."id" IN ()
2014-03-12T09:40:00.600282+00:00 app[web.1]: Rendered refresh/index.html.erb within layouts/application (3.7ms)
2014-03-12T09:40:00.599548+00:00 app[web.1]: ^
2014-03-12T09:40:00.600282+00:00 app[web.1]: Rendered refresh/index.html.erb within layouts/application (3.7ms)
2014-03-12T09:40:00.599548+00:00 app[web.1]: PG::Error: ERROR: syntax error at or near ")"
2014-03-12T09:40:00.600424+00:00 app[web.1]: Completed 500 Internal Server Error in 106ms
2014-03-12T09:40:00.592159+00:00 app[web.1]: Event Load (5.2ms) SELECT "events".* FROM "events" INNER JOIN "eligibles_events" ON "events"."id" = "eligibles_events"."event_id" WHERE "eligibles_events"."eligible_id" = $1 [["eligible_id", 4]]
2014-03-12T09:40:00.599548+00:00 app[web.1]: LINE 1: SELECT "events".* FROM "events" WHERE "events"."id" IN ()
2014-03-12T09:40:00.602492+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR: syntax error at or near ")"
2014-03-12T09:40:00.602492+00:00 app[web.1]: ^
2014-03-12T09:40:00.602492+00:00 app[web.1]: : SELECT "events".* FROM "events" WHERE "events"."id" IN ()):
2014-03-12T09:40:00.602492+00:00 app[web.1]: 2: <b> <%= #cat.name if #cat.present? %> <%= #dom.name if #dom.present? %> <%= #eli.name if #eli.present? %></b>
2014-03-12T09:40:00.602492+00:00 app[web.1]: 4:
2014-03-12T09:40:00.602492+00:00 app[web.1]: LINE 1: SELECT "events".* FROM "events" WHERE "events"."id" IN ()
2014-03-12T09:40:00.602492+00:00 app[web.1]: 1: <div class="container">
2014-03-12T09:40:00.599548+00:00 app[web.1]: PG::Error: ERROR: syntax error at or near ")"
2014-03-12T09:40:00.602693+00:00 app[web.1]: 6: <script type="text/javascript" language="javascript" charset="utf-8">
2014-03-12T09:40:00.602693+00:00 app[web.1]: app/views/refresh/index.html.erb:3:in `_app_views_refresh_index_html_erb___3814188212292096351_70209931602340'
2014-03-12T09:40:00.602693+00:00 app[web.1]:
2014-03-12T09:40:00.602693+00:00 app[web.1]:
2014-03-12T09:40:00.602693+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR: syntax error at or near ")"
2014-03-12T09:40:00.602693+00:00 app[web.1]: ^
2014-03-12T09:40:00.600424+00:00 app[web.1]: Completed 500 Internal Server Error in 106ms
2014-03-12T09:40:00.602693+00:00 app[web.1]: 1: <div class="container">
2014-03-12T09:40:00.602881+00:00 app[web.1]: 2: <b> <%= #cat.name if #cat.present? %> <%= #dom.name if #dom.present? %> <%= #eli.name if #eli.present? %></b>
2014-03-12T09:40:00.602881+00:00 app[web.1]: 4:
2014-03-12T09:40:00.602881+00:00 app[web.1]:
2014-03-12T09:40:00.602693+00:00 app[web.1]: : SELECT "events".* FROM "events" WHERE "events"."id" IN ()):
2014-03-12T09:40:00.602492+00:00 app[web.1]: 3: <%= render partial: "static_pages/event", collection: #all %>
2014-03-12T09:40:00.602693+00:00 app[web.1]: LINE 1: SELECT "events".* FROM "events" WHERE "events"."id" IN ()
2014-03-12T09:40:00.602881+00:00 app[web.1]: 3: <%= render partial: "static_pages/event", collection: #all %>
2014-03-12T09:40:00.602881+00:00 app[web.1]: 5: </div>
2014-03-12T09:40:00.602693+00:00 app[web.1]:
2014-03-12T09:40:00.602881+00:00 app[web.1]: 6: <script type="text/javascript" language="javascript" charset="utf-8">
2014-03-12T09:40:00.602492+00:00 app[web.1]:
2014-03-12T09:40:00.602881+00:00 app[web.1]:
2014-03-12T09:40:00.602492+00:00 app[web.1]: 5: </div>
2014-03-12T09:40:00.602881+00:00 app[web.1]: app/views/refresh/index.html.erb:3:in `_app_views_refresh_index_html_erb___3814188212292096351_70209931602340'
2014-03-12T09:40:00.967239+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=floating-castle-4592.herokuapp.com request_id=d1fe2f58-7a19-42dc-9ef4-940d4841d822 fwd="122.167.180.66" dyno=web.1 connect=2ms service=7ms status=200 bytes=228
2014-03-12T09:40:00.609749+00:00 heroku[router]: at=info method=GET path=/refresh?utf8=%E2%9C%93&category%5Bcategory_id%5D=&domain%5Bdomain_id%5D=&eligible%5Beligible_id%5D=4&commit=Search host=floating-castle-4592.herokuapp.com request_id=578810a1-52fc-4d2a-a095-97a8983d926b fwd="122.167.180.66" dyno=web.1 connect=1ms service=243ms status=500 bytes=1543
Edits:
Also, I would like to know how to sort the events w.r.t to their popularity in the selection.
I think this is your problem:
#e_1 << #cat.events.collect{|p| p.id} if #cat.present?
#e_2 << #dom.events.collect{|p| p.id} if #dom.present?
#e_3 << #eli.events.collect{|p| p.id} if #eli.present?
#e_f = #e_1 | #e_2 | #e_3
#all = Event.where(id: #e_f)
In this case, if #e_1, #e_2 and #e_3 are all blank (nil) then #e_f is nil, then you do this
#all = Event.where(id: nil)
and i think that's what's causing your sql problem.
A much nicer way of doing what you want to do is this:
def index
#cat = Category.find(params[:category][:category_id]) if params[:category][:category_id].present?
#dom = Domain.find(params[:domain][:domain_id]) if params[:domain][:domain_id].present?
#eli = Eligible.find(params[:eligible][:eligible_id]) if params[:eligible][:eligible_id].present?
#all = Event.find([#cat, #dom, #eli].reject(&:blank?).collect(&:event_ids).flatten.uniq)
#user = current_user || User.new
end
I think this could be refactored further too, there's still a lot of repetition.
EDIT: you asked about ordering the results by most popular first. Here's one way, it's probably not the most efficient and almost certainly not the prettiest. It uses 'order by field(columname, values)` which is a way to specify an ordering in sql.
def index
#cat = Category.find(params[:category][:category_id]) if params[:category][:category_id].present?
#dom = Domain.find(params[:domain][:domain_id]) if params[:domain][:domain_id].present?
#eli = Eligible.find(params[:eligible][:eligible_id]) if params[:eligible][:eligible_id].present?
ids = [#cat, #dom, #eli].reject(&:blank?).collect(&:event_ids).flatten
sorted_ids = ids.sort_by{|id| ids.select{|id2| id2 == id}.size}.reverse
#all = Event.find(sorted_ids, :order => "field(id, #{sorted_ids.join(",")})" )
#user = current_user || User.new
end
This is the error:
ActionView::Template::Error (PG::Error: ERROR: syntax error at or near ")"
SELECT "events".* FROM "events" WHERE "events"."id" IN ())
We had a similar issue before -- it's basically that PGSql is not as forgiving as MYSQL or SQLite etc. I would say the best way to fix this is to refactor your code:
def index
cat = params[:category][:category_id]
domain = params[:domain][:domain_id]
eli = params[:eligible][:eligible_id]
queries = [cat, domain, eli]
queries.each_with_index do |query, i|
if query.present?
instance_variable_set("##{query}", Category.find(query))
e = instance_variable_get("##{query}")
instance_variable_set("#e_#{i}" = e.events.collect{|p| p.id}) if defined?(e)
end
end
#all = Event.where(id: [#e_1, #e_2, #e_3])
#user = current_user || User.new
end
This probably won't work at first, but with some fixing, I'm sure it will fix any of the issues you've been having
I have just pushed a rails project to heroku, but I get the "We're sorry, but something went wrong."-error when I try to visit the web address. I did heroku run rake db:migrate just after I uploaded the project. Does someone know what the issue might be?
2013-07-07T03:18:40.493412+00:00 heroku[web.1]: State changed from starting to up
2013-07-07T03:19:30.121757+00:00 app[web.1]: => Booting WEBrick
2013-07-07T03:19:30.121757+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:7276
2013-07-07T03:19:30.121757+00:00 app[web.1]: => Call with -d to detach
2013-07-07T03:19:30.121757+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-07-07T03:19:30.121757+00:00 app[web.1]: Started GET "/" for 216.15.124.94 at 2013-07-07 03:19:30 +0000
2013-07-07T03:19:30.298842+00:00 app[web.1]: Processing by PagesController#lelist as HTML
2013-07-07T03:19:30.683128+00:00 app[web.1]: Completed 500 Internal Server Error in 384ms
2013-07-07T03:19:30.680391+00:00 app[web.1]: Rendered pages/_singlePost.html.erb (39.1ms)
2013-07-07T03:19:30.687518+00:00 app[web.1]: 1: <% #posts.each do |p| %>
2013-07-07T03:19:30.682956+00:00 app[web.1]: Rendered pages/lelist.html.erb within layouts/application (122.9ms)
2013-07-07T03:19:30.687518+00:00 app[web.1]: 3: <div class="span6 offset3">
2013-07-07T03:19:30.687741+00:00 app[web.1]: app/views/pages/_singlePost.html.erb:1:in `_app_views_pages__single_ost_html_erb___4229188597617574554_47615640'
2013-07-07T03:19:30.687741+00:00 app[web.1]:
2013-07-07T03:19:30.687518+00:00 app[web.1]: 4: <div class="thumbnail">
2013-07-07T03:19:30.687741+00:00 app[web.1]: app/views/pages/lelist.html.erb:22:in `_app_views_pages_lelist_html_erb___4165065758361537325_47142940'
2013-07-07T03:19:30.687518+00:00 app[web.1]: LINE 1: SELECT "posts".* FROM "posts" WHERE (DATETIME(created_at) ...
2013-07-07T03:19:30.687518+00:00 app[web.1]: : SELECT "posts".* FROM "posts" WHERE (DATETIME(created_at) <= DATETIME('2013-07-07 03:19:30.364173')) ORDER BY created_at DESC LIMIT 10 OFFSET 0):
2013-07-07T03:19:30.687518+00:00 app[web.1]: HINT: No function matches the given name and argument types. You might need to add explicit type casts.
2013-07-07T03:19:30.687741+00:00 app[web.1]:
2013-07-07T03:19:30.687518+00:00 app[web.1]:
2013-07-07T03:19:30.687518+00:00 app[web.1]: ActionView::Template::Error (PGError: ERROR: function datetime(timestamp without time zone) does not exist
2013-07-07T03:19:30.687518+00:00 app[web.1]: 2: <div class="row">
A little further down in the log I get another error:
2013-07-07T03:35:54.804738+00:00 app[web.1]: ActionView::Template::Error (PGError: ERROR: function datetime(timestamp without time zone) does not exist
2013-07-07T03:35:54.804738+00:00 app[web.1]: LINE 1: SELECT "posts".* FROM "posts" WHERE (DATETIME(created_at) ...
2013-07-07T03:35:54.804738+00:00 app[web.1]: ^
2013-07-07T03:35:54.804738+00:00 app[web.1]: HINT: No function matches the given name and argument types. You might need to add explicit type casts.
2013-07-07T03:35:54.804738+00:00 app[web.1]: : SELECT "posts".* FROM "posts" WHERE (DATETIME(created_at) <= DATETIME('2013-07-07 03:35:54.572183')) ORDER BY created_at DESC LIMIT 10 OFFSET 0):
2013-07-07T03:35:54.804738+00:00 app[web.1]: 1: <% #posts.each do |p| %>
2013-07-07T03:35:54.804738+00:00 app[web.1]: 4: <div class="thumbnail">
2013-07-07T03:35:54.804738+00:00 app[web.1]: 2: <div class="row">
2013-07-07T03:35:54.804738+00:00 app[web.1]: 3: <div class="span6 offset3">
2013-07-07T03:35:54.804934+00:00 app[web.1]: app/views/pages/_singlePost.html.erb:1:in `_app_views_pages__single_ost_html_erb___4229188597617574554_47615640'
2013-07-07T03:35:54.804934+00:00 app[web.1]: app/views/pages/lelist.html.erb:22:in `_app_views_pages_lelist_html_erb___4165065758361537325_47142940'
Heroku uses postgresql for your database. DATETIME is not a function postgres supports. You should set up a postgresql database of the same version in your development environment. What OS are you on? If windows, I wrote any answer for that (some of it is applicable even if you're running linux).
In production (Heroku), I'm getting the following error:
Started GET "/articles/1" for 50.134.181.231 at 2012-06-17 00:37:35 +0000
2012-06-17T00:37:35+00:00 app[web.1]: ActionView::Template::Error ( isn't precompiled):
2012-06-17T00:37:35+00:00 heroku[router]: GET wandr.com/articles/1 dyno=web.1 queue=0 wait=0ms service=497ms status=500 bytes=728
2012-06-17T00:37:35+00:00 app[web.1]:
2012-06-17T00:37:35+00:00 app[web.1]: 74: = image_tag #article.featured_photo_url(:sm).to_s
2012-06-17T00:37:35+00:00 app[web.1]: 75:
2012-06-17T00:37:35+00:00 app[web.1]: 77: = image_tag #article.background_photo_url(:md).to_s
2012-06-17T00:37:35+00:00 app[web.1]: 76: %p
2012-06-17T00:37:35+00:00 app[web.1]: 78: %p
2012-06-17T00:37:35+00:00 app[web.1]: 79: = image_tag #article.cover_photo_url(:md).to_s
2012-06-17T00:37:35+00:00 app[web.1]: 80:
2012-06-17T00:37:35+00:00 app[web.1]: app/views/articles/show.html.haml:77:in `_app_views_articles_show_html_haml__1847247375488199378_48105500'
2012-06-17T00:37:35+00:00 app[web.1]:
2012-06-17T00:37:35+00:00 app[web.1]: app/controllers/articles_controller.rb:21:in `show'
2012-06-17T00:37:35+00:00 app[web.1]:
2012-06-17T00:37:35+00:00 app[web.1]: Processing by ArticlesController#show as HTML
2012-06-17T00:37:35+00:00 app[web.1]: Rendered articles/show.html.haml within layouts/admin (420.5ms)
2012-06-17T00:37:35+00:00 app[web.1]: Parameters: {"id"=>"1"}
2012-06-17T00:37:35+00:00 app[web.1]: Completed 500 Internal Server Error in 486ms
I'm running Rails 3.2.6, including actionpack 3.2.6 which I thought had this fix for this issue: https://github.com/rails/rails/commit/6bb86e1f3f7f9e11ee1c056d8742125173ecbce1
I also tried this: "ActionView::Template::Error ( isn't precompiled)" raised on "image_tag nil"
Basically, as long as one of the images on this page don't exist, it's throwing this error. If I upload the images, it works fine. Any ideas?
Thanks,
--Mark
I assume you're using something like CarrierWave to handle file uploads? You can specify a default image handler in your uploader class:
https://github.com/jnicklas/carrierwave#providing-a-default-url
class MyUploader < CarrierWave::Uploader::Base
def default_url
"/images/fallback/" + [version_name, "default.png"].compact.join('_')
end
end
This will output the default image rather than trying to access a non-existent file called "" in the asset pipeline.