similar to: Clearing dependent collections

Displaying 20 results from an estimated 6000 matches similar to: "Clearing dependent collections"

2006 Apr 15
1
Is this a HAS_ONE bug?
Let''s say I have: A BELONGS_TO B B HAS_ONE A (with :dependent=>:nullify) But this association does not need to exist. In other words, I could have many A''s and B''s that are not associated in this manner. Presently, if I try to delete "B": 1. If B is associated to an "A", this works fine and A.my_B is nullified. 2. If B is NOT associated, I
2006 Mar 29
5
How to skip password validation when updating other fields?
Besides the hashed password, which is saved to db, I have two password-attributes in my User model: attr_accessor :password, :password_confirmation I have validations on these attributes, and I need them to work both on create and update, since I have pages for changing and resetting the password. Now when I want to update just the user''s login name, I guess I have the next
2008 Feb 05
1
Functional Test has error when testing controller updates_attribute of its parrent.
I am working in Rails 2.0 and I have the following functional test. class VotesControllerTest < ActionController::TestCase def test_should_create_vote assert_difference(''Vote.count'') do post :create, {:vote => {:vote_value => 5, :user_id => users(:nick).id, :entry_id =>
2006 Jan 23
3
Clearing a file_column-type field
So I am now able to set/upload an image to my app using file_column, with a little bit of a change to the code. I can change the image using an Edit page, but I''m trying to figure out what to do if the user wants to remove the image. I tried adding a Remove Image link in my list, but I''m not sure what to do in the remove_image method in my controller. I tried setting the
2006 Jun 07
3
#5209 patch: :dependent => :nullify deletes child records
Hi everyone, A couple of weeks ago I noticed a bug with :dependent => :nullify on a has_many or has_one. When you delete the parent, the children''s foreign keys are nullified, as expected. But when you do parent.child.delete or parent.children.clear, ActiveRecord actually deletes the child records, rather than just nullifying them. In my eyes, if you''ve set
2008 Mar 07
0
ActiveRecordStore: cleanup & avoiding duplication
Hi, I''m using ActiveRecordStore to track user sessions. I''ve used as a base the next sources: - http://blog.levicole.com/articles/category/ror - http://matt-beedle.com/2006/12/13/rails-how-to-find-out-who-is-online/ - http://www.williambharding.com/blog/?p=99 This is what I currently do: IN SESSION CONTROLLER def create self.current_user = User.authenticate(params[:login],
2006 Jul 10
0
Dependent nullify doesn''t use save?
If you have a model that has has_many :clients, :dependent => :nullify Will that run the save method for each client or will it just simply nullify the foreign key using straight SQL without every calling save. Because I have some very important before_save code in my Client model and I do not think it is getting ran. Thanks for your help. Thank You, Ben Johnson E:
2007 Jun 25
1
has_many with :dependent => :nullify
Hi all, There is something confusing with has_many in the current API : When deleting a record with association.delete, the corresponding association''s foreign key is nullified. However, if has_many has the :dependent option set (to any value), the association''s destroy method is called instead. This is awfully inconsistent with the behavior expected when setting :dependent to
2006 Jun 01
0
question about observer callbacks
I''m not sure how to implement this so I''ll describe what I currently have done then what I wish to have happen currently, I have a generic observer for several models class AuditObserver < ActiveRecord::Observer observe Foo, Bar def after_update(model) model.log("UPDATED " + Time.now.strftime("%m-%d-%Y %H:%M")) end def after_create(model)
2006 Jun 12
0
struggling with relatively simple out of model updating
I''m trying to do a In/Out thing... In my in_outs_controller.rb def edit_in_out @in_out = InOut.new @in_out.user_id = params[:id] @user = User.find_by_id(@in_out.user_id) if @in_out.save @user.update_attribute(:in_out, params[:user][:in_out]) flash[:notice] = ''In/Out was successfully updated.'' redirect_to :action =>
2009 Oct 06
1
Problems Processing multiple form elements generated by javascript actions
Hi all, After many days of struggling, I have a multi-model form with ajax elements more or less working, but I''m hitting a wall with a few bugs that I can''t figure out. Guidance would be very much appreciated. I''m using the Ryan Bates technique from Advanced Rails recipes to dynamically add and remove elements on a multi-model form.
2006 Jun 12
0
validates_associated -- explicitly setting collection?
Hi, I have a class (say Parent) that has many of two other classes, say FirstChild and SecondChild. These could look like this: class Parent < ActiveRecord::Base has_many :first_children, :dependent => true has_many :first_children, :dependent => true validates_associated :first_children validates_associated :second_children end class FirstChild < ActiveRecord::Base
2006 Apr 14
3
Am I doing this right?
Hi everyone, I am following along with the book and branched out a bit to try some stuff on my own. I''ve been working on is a basic user management system - create a user, log in, log out, update your account, that sort of thing. I created a password changer that compares the old password (oldpw) against what''s currently in the database, then updates that record with the
2009 Nov 22
2
WARNING: Can't mass-assign these protected attributes: active
Hi, I''m trying to understand this error: WARNING: Can''t mass-assign these protected attributes: active I had this error before when creating a record.I did not mark the attibutes posted from the form as attr_accessible, so when the following line tries to execute it throwed an Warning in the log, and the record was not saved. @user = User.new(params[:user]) I find out that I
2011 Apr 06
2
Wish List: has_many :dependent => {}
I am after a nice way to disable (not destroy, delete nor nullify) all associated records. I''m a hoarder, I don''t want to get rid of anything but I want to stop records being visible. I have a disabled boolean in my tables and if I disable the top record in the association (say the association is 5-6 levels deep), I would like to cleanly disable its children. I''ve
2006 Jul 04
1
LoginGenerator Problem
I am trying to make a barebones login system based on this example (which in turn is just standard RoR login) but when I enter a user name and password, it says the login is unsuccessful every time. I am not sure where I am going wrong. Here is all relevent information CREATE TABLE `users` ( `id` int(6) unsigned NOT NULL auto_increment, `login` varchar(20) NOT NULL default
2006 Jun 04
2
Manipulating collections
I appreciate this is basic stuff but can''t seem to find the answer anywhere using Google. If someone could point me in the direction of some documentation on this I would be very appreciative. If I have a collection as follows: @stuff = Stuff.find_by_type(''new'') And I then want to add something onto it, how can I add to this collection? Additionally how could I go
2010 Sep 16
1
[RFC] function to parse string to argc/argv pair
Currently, I'm looking to improve rosh and would like to start using getopt(). I'd like to parse a string obtained by fgets() to be like the argc/argv pair created by __parse_argv but in a way that's more cross-platform (such that it can also be used by .lnx files rather than just COM32) and suitable to use in rosh and lua.c32. I've made a function and inlined a test program for
2011 May 21
1
Consequences of overriding update_attribute to force validation?
I know the debate of whether this should validate has been rehashed many times. My question is, what are the consequences of overriding this method to force validation? Will this break fundamental things? Will it break plugins? Is there a reason not to have a strict validation option? In my code I will never use this as I consider it a terribly broken method, but some gems use it and in one case
2007 Jul 17
5
habtm confusion
Hello friends! I am trying to make a database that will have a group of people set to committees, and a person can be in multiple committees, and a committee obviously has multiple people. The people are senators at my university. These are my current models: senator.rb: -- class Senator < ActiveRecord::Base validates_presence_of :first_name, :last_name, :floor has_and_belongs_to_many