search for: deleted_at

Displaying 20 results from an estimated 32 matches for "deleted_at".

2008 Feb 13
4
Migration Issues: Can't update newly added column values
Hello everyone, just wondering if anyone can help me with a migrations question here. Using: rails 2.0.2 ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin] mysql 5.0.45 Platform: windows xp The problem: ---------- I created a migration that is designed to add a column named "deleted_at" (timestamp) and then remove a column named "is_deleted" (boolean). The idea is to upgrade from merely tracking whether a record has been non-destructively deleted to tracking both if and when it has been non-destructively deleted. NULL values in "deleted_at" indicate a nor...
2006 Jan 31
2
find_by_sql question
I''m no good at SQL and I have a question that will hopefully be fairly easy to answer. I''m using acts_as_paranoid which instead of deleting a record adds a deleted_at column with the datetime the row was deleted. I want to have a find_by_sql filter out any row where deleted_at is not null. I have (at least the relevant parts): #a couple working filters here. filters << "crs.deleted_at IS NOT NULL" # THIS DOES NOT WORK filters = ''WHERE...
2009 Nov 20
7
Soft Deletes
...e are handling soft deletes in Rails. I''ve need a couple of gems/plugins that seem to handle this but from what I gather development has stopped on them. All I need to do right now is mark something as deleted in the DB...nothing fancy. I''m thinking that the simple addition of a deleted_at column, some named scopes (maybe even a default scope) and a handler on delete to set the deleted_at column and prevent the actual DB delete will do the trick. Any gotchas that I need to watch out for? Thanks in advance. Mike -- You received this message because you are subscribed to the Google...
2006 Jul 10
0
Strange acts_as_paranoid behavior
...also uses acts_as_threaded and acts_as_taggable) and getting some unexplainable behavior. The following tests: assert_equal Conv.count, num assert_equal Conv.count_with_deleted, CONVS_TOTAL Produce the following SQL: SQL (0.000000) SELECT count(*) AS count_all FROM convs WHERE (( convs.deleted_at IS NULL OR convs.deleted_at > ''2006-07-09 19:46:18'' ) AND ( convs.deleted_at IS NULL OR convs.deleted_at > ''2006-07-09 19:46:18'' )) SQL (0.000000) SELECT count(*) AS count_all FROM convs WHERE (convs.deleted_at IS NULL OR convs.deleted_at > '...
2013 Jun 15
1
A puzzle about default_scope
Hi, guys I have a puzzle about default_scope. Suppose I have two model: class User < ActiveRecord::Base has_many :blogs default_scope where(deleted_at: nil) end class Blog < ActiveRecord::Base belongs_to :user end I want to produce sqlselect blogs.* from blogs inner join users on users.id = blogs.user_id and users.deleted_at is null And the code Blog.joins(:user), which I think is good, produceselect blogs.* from blogs inner join users...
2006 Mar 14
2
acts_as_paranoid and :include
...own to an :include? For instance class parent acts_as_paranoid has_many: children end and class child acts_as_paranoid belongs_to :parent end Then if you Parent.find(:all, :include => children) you will get all the children if they are deleted or not. I guess the find that filters out the deleted_at is null does not filter down to the includes like this. -- Regards, Ian Connor -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060314/539fa473/attachment.html
2007 Aug 03
0
acts_as_paranoid and Association Extensions (has_one troubles)
...nd end end Loading development environment. >> sc = SportClub.find_with_deleted(7) => #<SportClub:0xb769c1a4 @attributes={"number_of_members"=>nil, "name"=>"Maastricht Wildcats", "updated_at"=>"2007-08-03 21:50:44", "deleted_at"=>nil, "created_by"=>nil, "organization_code"=>"KNVB347", "url"=>nil, "type"=>"SportClub", "updated_by"=>nil, "id"=>"7", "description"=>"", "deleted_by&quo...
2006 Mar 24
6
Should counter_cache fields be saved in the database?
As far as I can tell, the counter_cache option on a belongs_to model doesn''t actually save anything in the database. For example, I have the following models: class Parent < ActiveRecord::Base has_many :children, :conditions => "deleted_at IS NULL" end class Child < ActiveRecord::Base belongs_to :parent, :counter_cache => true end With the following schema, dumped from sqlite3: CREATE TABLE children ("id" INTEGER PRIMARY KEY NOT NULL NOT NULL, "name" varchar(255), "parent_id" integer, &qu...
2006 Mar 02
4
Getting Acts_as_Paranoid to work with validates_uniqueness_of
...table were I would like to use validates_uniqueness_of :company_name. This validation works if a company exists in the database and has not been deleted. However, I also would like the validates_uniqueness_of to work if a company has previously been deleted and has been flagged in the deleted_at column. Currently, if a company has been deleted, it is possible to create another company with the same name. I would like to bring up a validation message to inform the user. Is there an easy way to accomplish this? Any help would be greatly appreciated. Harvey -- Posted with http://...
2007 Jan 08
2
Two problems with Acts_as_paranoid
...es, if they have any solutions). 1. When using has_many :through, AAP doesn''t seem to take into account the fact that your join model might also be paranoid. My solution to this at the moment is to add an explicit conditions clause to the has_many :through statement, i.e. "join_model.deleted_at IS NULL" - is there a better way of getting the same result? 2. My tests sometimes fail in a random fashion. Looking at the test.log, nothing is different between test invocations, so the only conclusion I can come to is that it has something to do with the timestamp comparison sometimes work...
2006 May 11
0
acts_as_paranoid, aliasing and nested scopes in Rails 1.1
...cord::Base acts_as_paranoid acts_as_very_new #... end #--------------------------------------------------------------END In a controller I did the following calls: Book.find(:all) # SQL: SELECT * FROM books WHERE ((books.updated_at > ''2006-05-08 11:38:33'') AND (books.deleted_at IS NULL)) Book.find_with_old(:all) # SQL: SELECT * FROM books WHERE (books.deleted_at IS NULL) Book.find_with_deleted(:all) # SQL: SELECT * FROM books Isn''t is strange? Shouldn''t "Book.find_with_deleted(:all)" generate a "WHERE (books.updated_at > '...
2008 Apr 15
1
acts_as_paranoid Unknown key(s): with_deleted
Trying this straight from the README: I have acts_as_paranoid in my model (Course), and added the deleted_at column. This is OK: Course.find_with_deleted(:all) Course.find(:all, :with_deleted => true) gives: ArgumentError: Unknown key(s): with_deleted from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/core_ext/hash/keys.rb:49:in `assert_valid_keys'' from /opt/l...
2006 Aug 06
5
Return only results that user is allowed to see?
Is it possible with acts_as_ferret to somehow restrict the results that are returned? For instance, I don''t want to return results that are logically deleted with acts_as_paranoid (deleted_at IS NOT NULL and deleted_at < now()). Also, if a user is not an Admin, they should not be able to return results that have a certain value in a certain column, like forum_id != 13 (if 13 is an admin only forum). What''s the best way to accomplish this? Do I need to include the delete...
2010 Nov 30
4
Cucumber+Capybara rails 3 issue (Don't know where exactly)
...ECT "users".* FROM "users" WHERE ("users"."login" IS NULL) LIMIT 1 Notification Load (1.0ms) SELECT "notifications".* FROM "notifications" WHERE ("notifications"."user_id" = 1061) AND ("notifications"."deleted_at" IS NULL) AND ("notifications"."region" = ''top'') ORDER BY type DESC, created_at DESC Rendered partials/_notifications.html.haml (12.0ms) Person Load (0.7ms) SELECT "people"."id", "people"."first", "people&quo...
2009 Mar 19
6
[Cucumber 0.2] Failure to use should
...t = Account.find_by_name("my shiny new account") p account.class account.should_not be_blank end When running this step, I got the error message: Account(id: integer, name: string, state: string, next_renewal_at: date, created_at: datetime, updated_at: datetime, full_domain: string, deleted_at: datetime, subscription_discount_id: integer, subscription_plan_id: integer) And the account should be created # features/step_definitions/create_account_steps.rb:31 undefined method `be_blank'' for #<ActionController::Integration::Session:0x349994c> (NoMethodE...
2006 Jan 28
3
DRY conflict with "Updated at" "Created at" "Deleted at" in view
...p if ... well, you know ... <% for column in Product.columns.map %> <% next if column.name == ''id'' %> <% next if column.name ~= ''_id'' %> <% next if column.name == ''created_at'' %> <% next if column.name == ''deleted_at'' %> <% next if column.name == ''contact_id'' %> Thanx! Gerard. -- "Who cares if it doesn''t do anything? It was made with our new Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..." My $Grtz =~ Gerard; ~ :wq!
2008 Feb 12
0
acts_as_paranoid: has_one_paranoid
...eems to work for me: module ActiveRecord class Base def self.has_one_paranoid(*args) ref = create_has_one_reflection *args cond = args.last[:conditions] cond = cond.blank? ? '''' : cond + '' AND'' cond << " (#{ref.table_name}.deleted_at IS NULL OR #{ref.table_name}.deleted_at > ''#{Time.now.to_s(:db)}'')" args.last[:conditions] = cond has_one *args end end end I have two questions about it: 1) where''s a good place to post it to get it into trunk, rubyforge''s tracker didn...
2006 Apr 22
2
Question about functional tests and log/test.log
...t; "email"=>"tmornini@bogus.com"}, "action"=>"attempt_login", > "controller"=>"user"} > [4;36;1mSQL (0.006807) [0;1mPRAGMA table_info(users) > [4;35;1mUser Load (0.000963) SELECT * FROM users WHERE > (users.deleted_at IS NULL) AND (email = ''tmornini@bogus.com'' and > hashed_password = ''5d0527d81f6c2d901a0a2d889cb73f9499402626'' and > verified = ''t'') LIMIT 1 > Rendering layoutfalseactionlogin within layouts/application > Rendering user/login >...
2008 Jul 28
1
callback executed like after_save but after transaction
...ame table represented by my model class so when it runs it needs the database to be up to date. In the following situation this is fine: # MyModel def after_save `/usr/local/bin/update_models -i #{self.id}` end # controller action delete def delete MyModel.find(params[:id]).update_attribute(:deleted_at, Time.now) # after_save is called when the table end But in this situation: # controller action new def new MyModel.transaction do newmodel = MyModel.new othermodel = MyOtherModel.new ... other code ... newmodel.save! othermodel.save! end end after_save gets called inside...
2007 May 11
3
is_active?
Hey all, i''m rather new to rails and was curious if ActiveRecord implemented anything like is_active where the delete functions would just mark records as inactive, vs deleting rows. (similar to created_at, etc). I need a history of transactions, and this is how I would code in other languages. Any advice? Is there are smarter way to implement this? Thanks in advance! -- Posted via