Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method utc for string #81

Open
AlanLattimore opened this issue Sep 10, 2020 · 3 comments
Open

undefined method utc for string #81

AlanLattimore opened this issue Sep 10, 2020 · 3 comments

Comments

@AlanLattimore
Copy link

Dependencies

PgSQL 12
ruby: 2.6.5
rails: 5.2.3
pg: 1.1.4
que: 1.0.0.beta4 (commit 065981)
que-web: HEAD (commit 3f7b7b7)

Reproduce Condition

Visit /que/scheduled

How System Behaves

  • System displays the message:
NoMethodError at /que/scheduled
undefined method `utc' for "2020-09-06 22:17:03":String
in que-web/lib/que/web.rb in relative_time:188
que-web/web/views/scheduled.erb:26

My best guess so far is que-web/lib/que/web.rb:39

scheduled_jobs = Que.execute SQL[:scheduled_jobs], [pager.page_size, pager.offset, search]

returns run_at as a string, example: "2020-09-06 22:17:03"

The relative_time helper expects a Time object at lib/que/web.rb:189

      def relative_time(time)
        %{<time class="timeago" datetime="#{time.utc.iso8601}">#{time.utc}</time>}
      end

and the String class is missing .utc

Proposed Solution

https://github.com/AlanLattimore/que-web/tree/undefined-method-utc-for-string

      def relative_time(time)
        time = Time.parse(time) if time.is_a?(String)
        %{<time class="timeago" datetime="#{time.utc.iso8601}">#{time.utc}</time>}
      end

based on que-rb/que@87d40e7

@AlanLattimore
Copy link
Author

I understand that que: 1.0.0.beta4 is not supported but I've done the research and I hope this might help someone else.

@statianzo
Copy link
Owner

Thanks for digging in @AlanLattimore. Looks good to me. Can you make this a PR and add a test to spec/web_spec.rb?

@AlanLattimore
Copy link
Author

Will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants