1

I am trying to make a calendar in Ruby and it works locally but when I push it to heroku it throws a 500 error.

This is the line that is broken

<%= calendar @date do |date| %>

This is my controller

class CalendarController < ApplicationController
  before_action :logged_in_user, only: :show
  def show
    @date = params[:date] ? Date.parse(params[:date]) : Date.today
    @nealdocuments = Nealdocument.all
  end
end

The error is

at=info method=GET path="/calendar" host=mysite.herokuapp.com request_id=cacc46e7-455e-47d4-81a7-2fa0a1cc1d14 fwd="67.245.106.146" dyno=web.1 connect=0ms service=159ms status=500 bytes=1785 protocol=https

and

2019-06-05T14:41:01.893927+00:00 app[web.1]: F, [2019-06-05T14:41:01.893864 #17] FATAL -- : [cacc46e7-455e-47d4-81a7-2fa0a1cc1d14] ActionView::Template::Error (uninitialized constant CalendarHelper::Calendar
2019-06-05T14:41:01.893930+00:00 app[web.1]: Did you mean?  CalendarHelper):

Without that one line though the page loads.

This is my Helper class

module CalendarHelper
  def calendar(date = Date.today, &block)
    Calendar.new(self, date, block).table
  end
end
6
  • You could try ::Calendar.new(...) instead of Calendar.new(...).
    – jvillian
    Jun 5, 2019 at 14:52
  • @jvillian Thanks for the try but it didnt work Jun 5, 2019 at 15:00
  • is Calendar an ActiveRecord class?. This seem like a loading order issue, or something with eager loading class related. What Rails version are you using ?. Try running the app on your computer using production environment, just as it runs on Heroku. I bet you'll get the same error. That way you can debug what's going on.
    – fanta
    Jun 5, 2019 at 15:16
  • @fanta it is not an ActiveRecord class. Should i make it into one? If so, how would I do that? Jun 5, 2019 at 15:30
  • No no, you don't have to do that. I was just wondering if it was one of those, if so, it would be really strange if you had that issue, but it isn't. So, where does your class live ?, which directory ?. And as I said before, run your app i production env on your computer, you should have the same error if you do it.
    – fanta
    Jun 5, 2019 at 15:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.