Forum: Ruby on Rails ActiveRecord and SQL Server

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9a6f3398de74ae24042a880b18d8c36d?d=identicon&s=25 Ed Silva (Guest)
on 2006-05-04 16:38
(Received via mailing list)
Hi all,

I am exploring using RoR for a new project but have run into a
problem with ActiveRecord and SQL Server's timestamp datatype.

We have a NOT NULL timestamp column in a table and ActiveRecord keeps
trying to update it, which promptly causes it to blow up. I have
tried making the value NULL for insert and update in the model, but
SQL Server doesn't like that either.

Is there any way to get ActiveRecord to just completely ignore that
column short of using a view to hide it?

Cheers,

--Ed
22ff4abebc9bfd299524bb14449d95dc?d=identicon&s=25 Erik van Oosten (Guest)
on 2006-05-04 16:38
(Received via mailing list)
What is the name of the column?

     Erik.

Ed Silva schreef:
2f46d76f0e5db4dc318b03be07ebaac4?d=identicon&s=25 Tom Ward (Guest)
on 2006-05-05 15:59
(Received via mailing list)
On 5/4/06, Ed Silva <ed@litmusgreen.com> wrote:
> Is there any way to get ActiveRecord to just completely ignore that
> column short of using a view to hide it?

Off the top of my head, something like this may work:

class Record < ActiveRecord::Base
  def self.columns
    super.reject {|c| c.name == "timestamp"}
  end
end

Tom
9a6f3398de74ae24042a880b18d8c36d?d=identicon&s=25 Ed Silva (Guest)
on 2006-05-05 16:36
(Received via mailing list)
This did the trick, thanks! Now I won't have to use perl for this
project! :-)

Cheers,

--Ed
This topic is locked and can not be replied to.