Displaying 20 results from an estimated 9000 matches similar to: "ActiveRecord and SQL Server"
2007 Sep 07
6
ActiveRecord::Base#update_all expected behaviour
Hi
I noticed that if in my code I use the following:
Photo.update_all("title = ''Ruby rocks'' ", "id IN (#{@photo_ids})")
All my objects are properly updated but none of the filters/callbacks
are triggered. Is that what''s expected?
I have a before_update filter set on the Photo class and it gets
totally ignored, I guess the only way to solve this
2006 Mar 16
1
sql functions in cru ( not d )
Hi,
I''m looking at ways to encrypt email addresses rather than storing
them directly in the database.
There are several ways that it could be done. I could make an
Encrypter class and use before_update, etc. Or I could set up an
updatable VIEW in mySql. (I guess triggers might be another
possibility.)
However, what I would really LIKE to do is use the handy AES_ENCRYPT
and
2008 Feb 26
5
Rails 2.0.2 MySQL 'year' datatype missing from ActiveRecord?
Hi all,
This is my first post to the forum, and I''ll point out right away that
I''m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that I''m
wrong here, but is the ''year'' datatype missing from ActiveRecord in
2.0.2? According to my MySQL 5.0 reference manual, ''year'' is a datatype,
but when I try to run a migration that has
2007 Jan 04
6
after_update attributes problem
Hey guys,
I''m having a hard time w/ the after_update callback on rails... As
far as I can tell, when I define a after_update callback on a model,
the attributes of the object have the same values that they had
*before* Base.save was called. I''m probably wrong so here''s the code:
UNIT TEST:
def test_register_item_adjusts_account_balance
account =
2007 Mar 17
4
Created_on and updated_on in a non-ActiveRecord model
Hi you all,
I have a model simulating an ActiveRecord model, according to the tips
stated in [1]. It is simulated because even though I am gonna save the
attributes in a file, not in a DB, I still want the validations made by
ActiveRecord::Base (see code below).
Well, the thing is that I also want the behaviour of the created_on and
updated_on columns, that get modified automatically before
2008 Feb 03
1
ActiveRecord object.valid? triggers unexepected results
I''m editing an ActiveRecord object in a session through AJAX, updating
it with object.attributes = params[:object], and validating it with
object.valid?
Because it''s associated with other objects in a form, I want to save
them all together.
The surprise was that object.valid? triggers after_validation_on_update.
I''m having an audit log and I was getting bogus entries.
2015 Oct 16
2
pjsip database error when using MS SQL via ODBC
I have a project that is requiring the use of MS SQL from asterisk. I get
an error when the pjsip contact tries to update the contact table.
[Oct 15 21:34:55] WARNING[3033]: res_odbc.c:649
ast_odbc_prepare_and_execute: SQL Execute returned an error -1: 22018:
[FreeTDS][SQL Server]Conversion failed when converting the varchar value
'3.000000' to data type int. (101)
The datatype
2006 May 08
4
gsub no workie
Don''t know why, but cant seem to get this to work for me.
I have a phone number field for an addressbook. In the addressbook model
I have a before_update declaration that says the following:
I''d like to be able to remove all special characters (just numbers
please), but this doesn''t want to work for me.
before_update :format_phone
def format_phone
self.phone =
2007 Dec 15
2
Reading Model data before update
Hi all,
here is the challenge:
I have this validation method, that basically prevents an object which
billed = true to be updated:
def before_update
if read_attribute(:billed)
errors.add_to_base(''This service has already been billed for'')
end
!read_attribute(:billed)
end
The above code does not work in case I do something like:
object =
2006 Feb 22
3
after_update: old, new values?
With after triggers in Postgres, there are special NEW and OLD vars
accessible to trigger functions. Any such thing in Rails? Or would it
entail doing something like setting a class var in before_update?
Jack
--
Posted via http://www.ruby-forum.com/.
2006 Jan 20
47
SQL Server datetime error
i have a problem with the datetime format of rails. i am unable to save
a dataset to the db. here''s the error message -- the original error
message was in german, so i translated it -- i get:
DBI::DatabaseError: Execute
OLE error code:80040E07 in Microsoft OLE DB Provider for SQL Server
Couldn''t convert a char-Datatype to datetime
HRESULT error code:0x80020009
2006 Jul 05
1
ActiveRecord / PostgreSQL Performance Issue
I''m currently using ruby-postgres (the compiled interface to
PostgreSQL), and I''m seeing a huge performance hit with larger :binary
fields in ActiveRecord subclasses owing, it appears, to the use of the
bytea field type and the fact that using that datatype necessitates an
in-memory "unescape" conversion. The best I can tell from looking at the
Postgres Active
2012 Jul 18
5
Any comment on adding #cast and #cast! to ActiveRecord::Relation?
Not getting any love (tender or otherwise) on my pull
request<https://github.com/rails/rails/pull/7035>so I thought you
folks might like to chip in. What do you think?
#cast and #cast! allow you to declare a mapping from generated column names
to simplified
database column types (i.e. those used in migrations). This way scopes with
columns generated in their select lists can also include
2006 Jun 28
3
how do I validate currency format if I am storing in cents?
Hi all -
To avoid floating point issues, I''ve decided to store monetary values in
cents in the database. However, the user will enter these in dollars
and cents. Two questions:
1) How do I do the validation for the currency format? It looks like
ActiveRecord truncates the cents since it thinks the field type is a
Fixnum. Am I forced to do validation in the controller?
2) Where
2006 Jul 06
1
<model>.update(...) not calling before_update callback.
Hi,
I''m doing a <model_name>.update(....) but I''m noticing that my
before_update callback is not being called. If I do a find and then a
save!, I notice that it is called. The problem with a find and save in
my case is that I''m not able to set all my attributes in one shot by
saving params["user"] and since I can''t do this, my overloaded
2006 Jun 23
10
Don''t un-admin the last administrator
I have a User class with a field called admin which is a boolean that
determines if the user is or is not an administrator. I want to make it
impossible for the last administrator for an account to be removed from
the system.
I need to protect against this both when deleting a user and when
editing a user as you can revoke a user''s administrator privileges via a
form.
User
2006 Aug 09
1
How to Disable Callbacks on a Model
Does anyone know how to disable a model''s callbacks?
I have a routine that increments a page_view counter for various model
objects in an after_filter in my ApplicationController. I call this:
increment_page_view()
Rather that checking through the trace array in each model callback for
"increment_page_view" I''d rather disable the callbacks from inside
2008 Nov 03
17
SQL queries in Rails
Hi...
I want to know the equivalent instructions to insert, update, search
and delete a registry. I know Rails can do it easily Thanks to
ActiveRecord, but here''s the catch: I''m using PostgreSQL. As I''m using
SQL to do the migration (Including the foreign keys), I need to know
if I can use SQL queries to do those actions. Is there an example out
there?
I uncommented
2011 Jun 10
2
Sorting Data Frame Without Loop
Hello all!
I am currently trying to sort a data frame in a particular way, but I am having some difficulties with this. Specifically I want to sort the below dataset in such a way that there is only one line per ProteinID and if there are multiple GeneID or GeneName entries for a single proteinID, that they be concatenated with a comma separating them. The way I have done it earlier worked fine
2006 Feb 17
5
getting old values
Hi all,
I''ve add :before_update event to my model
Before updating a record I want to check if new attributes differ to old attr.
My question is how to retrieve old attributes in :before_update event ?
thanks
--
gratis egold 1$ http://shegold.com/