Displaying 6 results from an estimated 6 matches for "quote_value".
2008 Oct 21
6
detecting width overflow in serialized column with mysql
So I''ve got an ActiveRecord model pointing to a MySQL db, with an
auto-serialized column ("serialize :columnName").
Thing is, MySQL, depending on how it''s configured (like, by default),
has a bad habit of just truncating your data if it''s too wide for the
column, with no error raised. Yeah, I can probably reconfigure MySQL
and/or my AR connection to it. But
2007 Nov 14
1
has_many_polymorphs and acts_as_list ?
...longing <
ActiveRecord::Base
2 belongs_to :collector,
3 :class_name => "Collection",
4 :foreign_key => "collector_id"
5 belongs_to :element, :polymorphic => true
6 acts_as_list :scope => ''element_id=#{element_id} and
element_type=#{quote_value element_type}''
7 end
The belongings database table structure:
collector_id (integer) ; element_id (integer) ; element_type
(string) ; position (integer)
The self referential polymorphic aspect works like a charm!
But the acts_as_list doesn''t!
Here a demonstration inside the c...
2009 Mar 03
2
Passing an SQL fragment in AR save
I have a basic model class TestTime with no customization.
class TestTime < ActiveRecord::Base
end
I would like to pass the following SQL fragment as part of an AR save
call to TestTime objects. How and where would I do this in the model?
"set c_time=current_time"
(current_time is an SQL method, not a variable).
--
Posted via http://www.ruby-forum.com/.
2008 Sep 25
1
defining polymorphic type condition
...ct_sql
case
when @reflection.options[:as]
@finder_sql =
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id
= #{@owner.quoted_id} AND " +
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type
= #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}"
else
@finder_sql =
"#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} =
#{@owner.quoted_id}"
end
@finder_sql << " AND (#{conditions})" if conditions
end
This cannot easily be...
2010 Apr 20
13
why is ActiveRecord tying to select nonex ID column?
I''ve loaded (and updated) thousands of these MeteredUsage records. In
the middle of a run, I suddenly get:
ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ''id'' in
''where clause'': UPDATE `metered_usages` SET `cost` = 12603.46 WHERE `id`
= NULL
I can''t see anything that''s different about this particular record
compared to
2009 Jan 11
6
Why does ActiveRecord allow perception of success when updating an ID, however it doesn't really work(i.e. no change in database)?
Hi,
Why does ActiveRecord allow perception of success when updating an ID,
however it doesn''t really work(i.e. no change in database)?
Here''s an example. The update of "id" versus update of a non-existent
attribute.
?> ai = AccountItem.find(:first) => #<AccountItem id: 1, account_id: 1,
date: "2009-01-11", amount: