Skip to content

Instantly share code, notes, and snippets.

@stuffness
Created October 30, 2011 01:03
Show Gist options
  • Save stuffness/1325322 to your computer and use it in GitHub Desktop.
Save stuffness/1325322 to your computer and use it in GitHub Desktop.
#timers_helper.rb
module TimersHelper
def seconds_left
[(@timer.target - Time.now).round, 0].max
end
end
#timers_controller.rb
def refresh
@timer = Timer.find(params[:id])
render js: seconds_left
end
#the seconds_left helper works fine in the view, but in the controller I get this:
#NameError in TimersController#ajaxrefresh
#undefined local variable or method `seconds_left' for #<TimersController:0x6ef58d8>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment