Skip to content

Commit

Permalink
add timecop_console_layout helper
Browse files Browse the repository at this point in the history
helper method builds the basic layout needed to control your app server
time, method can also take in a block of html which is then inserted at
the top of the timecop console.
  • Loading branch information
ferndopolis committed Feb 28, 2014
1 parent d361409 commit f5f2a32
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/helpers/timecop_console/main_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,23 @@ def time_travel_to(date)
update_path,
method: :post)
end

def timecop_console_layout
if Rails.env.development? || Rails.env.staging?
content_tag(:div, id: "debug-console") do
concat(yield) if block_given?
concat(content_tag(:p) {
raw("<-- #{time_travel_to(24.hours.ago)}") +
"The time is #{Time.now.to_s(:db)}" +
raw("#{time_travel_to(24.hours.from_now)} -->");
})
concat(form_tag(timecop_console.update_path) {
concat(content_tag(:p, datetime_select("timecop", "current_time")));
concat(content_tag(:p, submit_tag( "Time Travel", class: 'btn')));
})
concat(link_to("Reset", timecop_console.reset_path))
end
end
end
end
end

0 comments on commit f5f2a32

Please sign in to comment.