Displaying 7 results from an estimated 7 matches for "attributes_before_type_cast".
2006 May 17
6
ActiveRecord#to_param
...thus only the object.id will be transmitted. Next I''ve tried some
approaches to stringinize or urlizie the contents of object and read and
searching the documentation. The closed I came up with was:
<%= link_to "action", {:action =>
"take_action"}.merge(object.attributes_before_type_cast) %>
This way I can see the data of the object in the @params Hash but
instead of the needed values "data" => {"attr1" => "value1", "attr2" =>
"value2"} I get a more flattened Hash: {"attr1" => "value1", "at...
2008 Mar 03
2
how can i know type of attribute with active record
Hello,
In my database, I have a table "products" with attributes :
- id
- title ->string
- desc -> text
I use active record, but I don''t know why recover the type of this
attribute with active record?
I try attributes_before_type_cast but I don''t see the type
Can you help me?
Excuse for my english (I''am a young student french)
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on...
2006 Mar 10
19
validates_date plugin for ActiveRecord
This plugin gives ActiveRecord the ability to do stricter date checking.
Example:
class Person < ActiveRecord::Base
validates_date :date_of_birth
end
This will ensure that date_of_birth is a *valid* date. The date can be set
initially as a string in any of the following formats:
"2006-01-01"
"1 Jan 06", or "1 Jan 2006"
"1/1/06" # Day /
2006 May 15
0
Execution expired with MONGREL. No problems with webrick
...lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:2068:in
`inject''
/opt/tools/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:2060:in
`clone_attributes''
/opt/tools/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1540:in
`attributes_before_type_cast''
/opt/tools/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1420:in
`clone''
lib/inorganic_parser.rb:153:in `get_results''
lib/inorganic_parser.rb:143:in `get_results''
app/controllers/uploader_controller.rb:86:in `parse_document''
app/c...
2006 May 16
1
ActionMailer w/o database link (e.g., feedback form)
Hey,
A total noobieQ. Apologies, still learning.
Could anyone point me to examples of a non-database-driven feedback
form, for instance, a simple e-mail feedback form that takes advantage
of ActionMailer? (How do I carry a POST through to a ''def'' w/o a
database connection?)
Thanks!
--
Posted via http://www.ruby-forum.com/.
2006 Mar 17
0
validates_format_of before type_cast?
Often I need to do a one-off validation before Rails has had a chance to
convert. For example, a date. Is there a general mechanism to cause
validations to run on the raw input or do I have to resort to:
private
def validate
unless attributes_before_type_cast[''date_of_loss''] =~
/^(\d+(-|\/)){2}\d{4}/
errors.add(''date_of_loss'', ''use the form: mm/dd/yyyy'')
end
end
Thanks
(BTW: I know there is a date validation plugin)
--
View this message in context: http://www.nabble.com/validates_format...
2010 Dec 30
6
validates_inclusion_of doesn't match constant
...odel Model:
SPECIAL_FEATURES = %w(none top)
class Model
validates_inclusion_of :special_feature, :in =>
Model::SPECIAL_FEATURES,
:on => :create, :message => "special_feature
%s is not defined"
belongs_to :team
def special_feature
attributes = attributes_before_type_cast
if attributes["special_feature"]
read_attribute(:special_feature).to_sym
else
nil
end
end
def special_feature=(value)
write_attribute(:special_feature, value.to_s)
end
end
In another class I do:
model = Model.new
model.special_feature = :none
model.sav...