Displaying 5 results from an estimated 5 matches for "attribute_before_type_cast".
Did you mean:
attributes_before_type_cast
2006 Jun 26
2
text_field weirdness?
I''m storying amounts of money in my database as cents.
So I have custom accessors in my model, for example
def actual_amount
read_attribute("actual_amount").to_f / 100.0
end
But when I use
<%= text_field ''item'', ''actual_amount'' %>
I get, for example, "3600" instead of "36.00".
If I ignore the helper, and
2006 Jan 31
1
Inserting NULL values into PostgreSQL from Rails
...regardless of the value that
is passed from a form. I am generating select tags with possible time
values, and I have added one additional one called ''none'' which I
want to insert a NULL value. I have tried all kinds of values for
this option tag, and even tried writing a attribute_before_type_cast
function and calling it via before_save to try and reset the value to
null or nil. I have had no luck.
So I am pretty sure that I am missing something- what do I have to do
to get Rails to allow an attribute to hold a NULL value and also
allow me to insert one into the database?
Thanks.
2006 Jul 02
7
How can I intercept attribute calls?
Hi.
I have two types of fields in my database, e.g. "name" and "name_ru".
First one is a user''s name in english and the second one is in russian.
I want to intercept calls like "c.name" and add "_ru" to it if current
language is russian (I have my own Locale class like n Globalize).
So I want such thing:
--
Locale.set("en-US")
c.name
2008 Jul 02
0
before_type_case broken?
Hey,
I''ve noticed that I seem unable to get a _before_type_cast value for
dates in 2.1. Specifically, if I assign a date string to a date
attribute, and then call attribute_before_type_cast I get a TimeWithZone
instead of a String:
model.start_date = "2001/01/02"
model.start_date.class = ActiveSupport::TimeWithZone
model.start_date_before_type_cast.class = ActiveSupport::TimeWithZone
Examining the @attributes in AR/lib/attribute_method.rb shows that the
entries are already...
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