Displaying 20 results from an estimated 800 matches similar to: "model methods"
2006 Mar 14
21
Changing default date format in Rails
I''ve spent all day digging through the rails api and postgres-pr on
this, I think it''s time to ask the list.
Postgres stores a Date in YYYY-MM-DD format. My users want the dates
in MM/DD/YYYY format.
Sure, I could explicitly convert it on the app level every place where
a date is displayed, but that seemed like a DRY violation.
I thought I''d be clever and simply
2006 Jan 09
5
Formatting timestamp objects
I want to print my timestamp objects in a specific format. I want to print
a date like this:
Sunday, January 8 2006
I don''t want it to print January 08.
For the time, I want it to look like this:
9:08 pm
Not 09:08 and lower case PM. I created these methods:
def format_date(date)
date.strftime("%A, %B #{date.day} #{date.year}")
end
def format_time(date)
if
2006 Jun 14
5
display formatted date
Hi,
In my form I have date field set as ''datetime_select'' which is fine as I
wanted it in the same format. But while displaying (list action) it
displays date in long format i.e. ''Tue May 30 15:39:00 Central Daylight
Time 2006''. How can I format it so that it will just be diaplyed as
''dd/mm/yyyy'' format?
Thanks
--
Posted via
2006 Jan 07
1
How to DRY with Fixtures (helper or extend Time class, how)?
I have a test/fixtures/users.yml like so:
apa:
id: 1
username: apa
[...]
created_at: <%=Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
updated_at: <%=Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
I don''t like how I''m repeating myself with the strftime bit.
Is there some shorter Time method to format time for a (MySQL) datetime
field that
2006 Jul 17
2
european date format
hi, overhere users go nuts if they have to enter the date in iso format,
so i have to make my applications in such a way that not only dates are
displayed in the "dd-mm-yyy" format but also can be entered in that way.
somewhere i found this code to put in the environment script:
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(
:default => ''%d/%m/%Y
2006 Mar 23
5
Custom date format
Hi, I''ve followed these directions :
http://railswiki.pdxruby.org/HowToDefineYourOwnDateFormat.html
It seems pretty straightforward but obviously it doesn''t work for me...
article.date_edited.to_formatted_s(:my_format_1)
produce a default formatted date, not the one I''ve defined in
environment.rb :
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(
2006 Apr 04
11
Date/Time format and syntax
Hi,
Just wondering how I get both the current date and time to display here
(so far I can only get the date OR the time):
@tblregisteredphone.txtregisterdatetime = Date.today
Also, how can I change the format of the date and time from:
Tue Apr 04 00:00:00 GMT Daylight Time 2006
to
2006-04-04 12:04:00
??
I''m sure it''s very simple, I just don''t know how
2009 Jun 15
1
calendardateselect problem
I am using http://code.google.com/p/calendardateselect/ for my date
time picker.
I am using dd.mm.yyyy format (:finnish)
and i am using
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!
(:default => "%d.%m.%Y")
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!
(:default => "%d.%m.%Y %H:%M")
in my enviroment. Everything is working
2010 Aug 13
4
Rails and Oracle - can select date but cannot save
I''m seeing a behavior in Rails that I find very strange. Having worked
quite a bit with Oracle with other languages I would always dutifully do
ALTER SESSION SET NLS_DATE_FORMAT = <my_date_format> and ensure I use
that date format in my application.
With Rails I still have not figured out how to execute an ALTER SESSION
statement after connecting to the database (I''m using
2006 Apr 15
2
Can''t run MySQL queries
Hi everyone,
I''m having trouble actually running mysql queries. I can connect to the
database, I think, but when a query gets run the following shows up in my
log:
SQL (0.000000) Mysql::Error: Lost connection to MySQL server during
query: SHOW TABLES
Any suggestions?
Thanks!
Daniel Higginbotham
2006 May 25
16
yet another rails site - happycarpools.com
I''m pretty much done with a project I''ve been developing to learn Rails,
http://www.happycarpools.com . If you could take a look, that''d be awesome!
Feedback would be even more awesome!
Probably the coolest thing about making this has been seeing how Rails does
*so much* and hardly has any superfluous parts, if any. There are so many
features that I initially
2004 Sep 21
5
R 1.9.1 Fails to Start on WinXP SP2
I have two computers both of which are running Windows XP SP2. R 1.9.1
runs just fine on one but not the other. Both installations of R came
from the same installation package. When I click on the desktop icon an
hourglass shows up then disappears. Similarly, if I start RGUI the
process shows up in task-manager then abruptly disappears.
Interestingly, I can access R in Excel via the D(COM) Server
2011 Feb 04
5
Date parse - month and day reversed
I am getting the month and day reversed in parsing a date. I am wondering if
there is some intelligence in Ruby that knows that at the moment I am in
Mexico, as the parsing is working as if I was
"6/15/2008".to_date
=> ArgumentError: invalid date
"15/6/2008".to_date
=> Sun, 15 Jun 2008
What I really want is my date to be understood as month/day/year. Is there a
way to
2006 May 10
2
Rails, Postgres and the Date Field.
Hi guys,
I''m having problems with my app. First of all, I created a date_select
with the code:
<%= date_select(''contact'', ''birthday'', :order => [''day'',''month'',''year'']) %>
In the contacts table, I create a date field:
birthday DATE
When I save the values goes wrong into the database.
2006 Apr 16
12
tired of using defined? all the time
Hi everyone,
It seems like every time I want to evaluate a possibly undefined variable I
have to use defined? to see that it exists first, so I can''t simply have
-- if params[:range_start] > 3
or something like it. I need to have
-- if defined? params[:range_start] && params[:range_start] > 3
I can''t even have
-- if params[:range_start].nil?
This is really
2006 Jan 23
3
date.to_s trimming
When I convert a datetime to a string, it prints out something like this
Jan 20 12:00:00 EST 2006
I want to trim off the last twelve characters, i.e.
:00 EST 2006
I tried to do it like so:
@date =
@meeting.date.to_s.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp
but the chomps seem to do nothing. I''d love to use regex, but I don''t
know which
2006 Jun 20
3
return unique rows with finders
I''m looking through the api for something like find(:all, :distinct => true)
so that multiple instances of a row won''t be returned - is this possible?
Thanks!
2006 Jun 27
6
Custom action on Active Record Validation Failure?
Instead of having it highlight the bad fields when you enter in a record
that fails validation, is there a way to make it do an action? I''m
looking for something like this:
validates_uniqueness_of :user_id,:url => {:controller => "headline",
:action => "index"}
so that on failing the uniqueness check, it would go to the headline
controller.
--
2006 Aug 03
5
Cannot find gem for Rails error from dispatch.cgi
Hi All,
I''m developing a Rails app with Rails v1.1.4, but when I upload it to
Dreamhost and try to serve it with dispatch.cgi, I get the error "Cannot find
gem for Rails =1.1.4". However, I have installed the 1.1.4 gem in my home
directory and set GEM_PATH to look there; additionally, rake throws no errors
and "rails -v" displays "Rails 1.1.4". Any
2006 May 18
4
time select with am/pm?
Hi everyone,
Is there a time select helper which uses a 12 hour clock rather than a 24
hour one? Also, does anyone know if :discard_year actually works in
datetime_select now, or how I could find this out?
Thanks!
Daniel