similar to: how can I use a the current_timestamp feature of a database without a magial column

Displaying 20 results from an estimated 10000 matches similar to: "how can I use a the current_timestamp feature of a database without a magial column"

2006 Jun 12
2
on_update current_timestamp in Migrations
Is there any way to set database columns to auto update a timestamp column on update? Can I do something like t.column "timestamp", :datetime, :default => :current_time, :null => false, :on_update => :current_timestamp or do i need to just use custom sql like sql = "ALTER TABLE `table` CHANGE `timestamp` `timestamp` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL
2009 Oct 16
5
Rails 2.3 Model.touch(:column) always also updates :updated_at???
Hi, Am I the only one (i.e. something I do is wrong), or does the touch- method always update updated_at, even though giving it a column to use INSTEAD is meant to update just that column??? Thanks, Michael
2006 Apr 20
0
Sqlite3 migration and CURRENT_TIMESTAMP
I''m trying out migrations for the first time, and I''m having a problem with my sqlite3 db. A trivial example of what I''m seeing: class InitDb < ActiveRecord::Migration def self.up create_table :mytable, :force => true do |t| t.column :lname, :string t.column :created_at, :string, :default =>
2006 Mar 30
15
ActiveRecord 1.13.2 -> 1.14.0 breaks Postgres connectivity
To Whom It May Concern: I have an ActiveRecord-based application (non-Rails). Life was grand until I upgraded ActiveRecord yesterday, after which point I was getting TONNES of these errors from my app and in PostgreSQL''s logs: FATAL: terminating connection due to administrator command According to Google searching, this happens when an external process sends PostgreSQL SIGINT or
2007 Oct 15
6
SQL injection with :order, :limit, :group
I know how to avoid SQL injection attacks when you use :conditions User.find :first, :conditions => ["login=?", params[:username]] but how about with :order, :limit or :group? # uh-oh...spaghetti-oh User.find :first, :order => "login; delete from users; select * from users" Pat --~--~---------~--~----~------------~-------~--~----~ You received this message because you
2012 Oct 23
7
Not updating the updated_at field
This is for Rails 3.1.1 I have a field called last_seen in a model. This field will be updated when the something about the record is seen in the real world (don''t worry about this part) So I go x.update_attribute(:last_seen, Time.now) and the following happens is UPDATE "blah" SET "last_seen" = ''2012-10-23 08:57:46.179288'', "updated_at"
2011 Jul 15
1
Rails 3 app has strange behaviour with Mysql2 database
Hi, I have developed a little web app with a sqlite3 database in development environment. Now I switched over to mysql2 for production environment. At a first look everthing looks good! BUT, I have delayed_jobs that run methods in the background, where two nested active records were compared with "if hash1 == hash2", then it should just show whether they are the same or not. With
2011 Oct 02
4
Aggregated attribute changed but _was is changed too. So nothing is update in database.
(Frenchy, sorry =) ) Hi everyone, i''ve got some troubles with aggregated attribute. I created a point and path class which receive postgresql point and path type data. Path object contains an array of point object. I''m currently working on a "hunting" module in web browser based game, and i need a crontab executed every n minutes to move the character on the map.
2013 Sep 11
1
when does 'updated_at' column get updated?
Using centos 6 with puppet-2.6.17 with thin_storeconfigs with mysql and nagios exported resources. Every time an agent connects to the master, the updated_at column in the hosts table is updated. However, the updated_at column in the other tables is not updated even when I alter a nagios resource attribute like retry_check_interval. What are the conditions by which the updated_at column is
2013 Feb 07
11
Rails change default time zone.
Hello everyone, I am using rails 3.2.8. I want to change time zone to New York time. I changed following, but didn''t work #config/application.rb config.time_zone = ''Eastern Time (US & Canada)'' config.active_record.default_timezone = ''Eastern Time (US & Canada)'' If am wrong please clarify. Thank You! -- You received this message
2009 Feb 11
6
Sessions do not update created_at column?
Hi All, I added a column to the sessions table called "created_at" in order to allow the created time to be recorded. However, different from other Models, the column does not update automatically. Therefore, what codes should I add to update the sessions."created_at" value? It is important for avoiding hacker keeping the sessions alive. Thanks much! Arthur -- Posted via
2007 Oct 13
4
Chapter 9
Hello, I''m currently stunk on this issue for few days and I do not know how to get it fixed. The system always raises this error message : order is closed and here is my order.rb: class Order < ActiveRecord::Base include ActiveMerchant::Billing before_validation :set_status attr_protected :id, :customer_ip, :status, :error_message, :updated_at, :created_at attr_accessor
2006 Feb 15
1
Per Database Migrations
Is there away to have parts of a migration file only work with a specific database. For example I am inserting some data into a table with: execute "INSERT INTO demo_lists(position, name, updated_at, created_at) VALUES (1, 1, ''scott'', CURDATE(), CURDATE());" Of course the curdate() function may only be available on mysql. So can we some how determine which
2010 Dec 09
15
Rails 3 Active Record query returns "undefined method `loaded?' for #<Array:0x126a4c>"
I am getting this error on an rspec test: undefined method `loaded?'' for #<Array:0x126a4c> When I call: Practice.includes("practice_members").all Practice has_many :practice_members PracticeMember belongs_to :practice Practice.all returns: [#<Practice id: 6, name: "Practice One", created_at: "2010-12-09 15:40:46", updated_at: "2010-12-09
2012 Feb 01
12
date validation in rails 3
consider scenario, User model with name, birth_date fields (here birth_date is not mandatory field) inside view form birth_date is assigned as ''31/31/1985'' which is invalid ideally user object should be invalid and while save raise an error on birth_date field but that''s not happening and user object gets saved with birth_date as blank which is completely misleading.
2011 Mar 01
11
Did rails or shoulda go insane on the inflection of 'taxes'?
I have a model ''xp_jurisdiction_taxes'' which rails (3) created correctly. Another model ''xp_jurisdiction_states'' has many :xp_jurisdiction_taxes. In my spec I am using a shoulda helper to test the association but get the following error. BTW, greped the whole project just in case and the string ''taxi'' exists nowhere. 1)
2006 Apr 05
3
how to insert Current DateTime value into database?
Hi, I want to insert onto database the Current DateTime Value into database field "Store_date" with datatype (DATETIME). How to do tihs? I am usiing hidden variable into my form as follows:- ======================= <%= hidden_field("store", "store_date", :value =>:datetime ) %> ======================= But when I m submmittng form I couldn''t find
2006 Mar 02
6
Newb question about facade columns
Hello, I am trying to deal with a database table that contains a date in the form of the number of seconds since epoch. Data is inserted in this format by an existing script that I can''t change, so a schema change isn''t realistic. I would like to allow humans to view and edit this data in the form of an actual human-readable date. I figured a facade column would be the
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:
2005 Dec 15
4
rake migrate ignores '':null => false'' on mysql
I wanted to add a login string column to an existing table => I created a migration : ... def self.up add_column "members", "login" , :string, :null => false end ... remark: it shouldn''t work, as the table is not empty (=> ''login'' would be null in the existing rows.) problem: rake migrate didn''t complain