From 5e584ee6264962cc60d9074c33141a28b4100607 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Thu, 27 Oct 2011 12:11:42 +0500 Subject: refactor lifetime_select helper --- app/helpers/snippets_helper.rb | 8 ++++---- app/views/snippets/_form.html.haml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/helpers/snippets_helper.rb b/app/helpers/snippets_helper.rb index cd7b03593c8..6a91d616722 100644 --- a/app/helpers/snippets_helper.rb +++ b/app/helpers/snippets_helper.rb @@ -1,10 +1,10 @@ module SnippetsHelper - def snippet_lifetime_select_options + def lifetime_select_options options = [ ['forever', nil], - ['1 day', Date.strptime("#{Date.current.day}.#{Date.current.month}.#{Date.current.year}", "%d.%m.%Y") + 1.day], - ['1 week', Date.strptime("#{Date.current.day}.#{Date.current.month}.#{Date.current.year}", "%d.%m.%Y") + 1.week], - ['1 month', Date.strptime("#{Date.current.day}.#{Date.current.month}.#{Date.current.year}", "%d.%m.%Y") + 1.month] + ['1 day', "#{Date.current + 1.day}"], + ['1 week', "#{Date.current + 1.week}"], + ['1 month', "#{Date.current + 1.month}"] ] options_for_select(options) end diff --git a/app/views/snippets/_form.html.haml b/app/views/snippets/_form.html.haml index 2c9680c028d..5cd0f74a0be 100644 --- a/app/views/snippets/_form.html.haml +++ b/app/views/snippets/_form.html.haml @@ -14,7 +14,7 @@ %td= f.text_field :file_name, :placeholder => "example.rb" %tr %td= f.label "Lifetime" - %td= f.select :expires_at, snippet_lifetime_select_options + %td= f.select :expires_at, lifetime_select_options %tr %td{:colspan => 2} = f.label :content, "Code" -- cgit v1.2.3