similar to: confirming that a model instance was correctly created from POST params

Displaying 17 results from an estimated 17 matches similar to: "confirming that a model instance was correctly created from POST params"

2006 Jun 01
4
how can I control when to commit a transaction?
hello it seems like this question has appeared a few times with no answer: how do you get rails to issue ''write'' statements (ie ''CREATE/UPDATE'') to the database without committing each time? I tried setting ActiveRecord::Base.connection.begin_db_transaction before calling any action on my object, but as soon as myObject.save or myObject.update is called,
2009 Jun 24
1
accepts_nested_attributes_for :reject_if issue
I have the following models: class Order < ActiveRecord::Base belongs_to :billing_address belongs_to :shipping_address accepts_nested_attributes_for :billing_address accepts_nested_attributes_for :shipping_address, :reject_if => proc { |attributes| attributes[''has_shipping_address''] != ''1'' } def after_initialize self.build_billing_address
2007 Dec 05
9
Does mock_model''s :null_object option work?
Please understand in the following that I am making relatively minor changes to legacy (non-TDD/BDD) code in Substruct and don''t have the time to refactor nicely right now. I''m just trying to get past the untested/un-speced cruft quickly to write the spec for my new code, so I''m looking for expediency over prettiness. I''m specifying before( :each ) do
2009 Feb 26
1
composed_of, aggregate object isn't saved
I am relatively new to rails and I cannot figure out what is going on here. I am using the composed_of method in an ActiveRecord class to create two aggregate properties: shipping_address and billing_address. The object properties are getting populated from the form and validation is working - no problem. When I call order.save, though, everything is being saved except the address fields. I am not
2006 Jun 06
1
Please Help with single table inheritance relationships
I''ve been searching the web, wikis, and more, and I haven''t turned up examples of how to have multiple entities in a single-table inheritance related to anything. I have an addresses table, but multiple entities can have Addresses: both Person (which has 2 addresses) and Retailer. I''ve been told that I need to use single-table inheritance, and this was my attempt:
2008 Jul 07
0
ActiveRecord in Rails 2.1.0 misbehaving for Aggregate Attr.
I am not sure if this is a bug in ActiveRecord or is this the intended behavior. If it is then it does not make sense to me. In a nutshell: If you change an aggregate object attribute created via composed_of method (see Agile Web Development - Second Edition Chapter 17 page 313 onwards) and then save the model, the change to the model (composite attribute specifically) will not be saved UNLESS
2008 Dec 02
4
Am I wrong or is fields_for not working right in Rails 2.2.2
I may be totally wrong about what the fields_for method is supposed to do, but for some reason I thought using it scoped an object around an association. For example, I have a User class and when you''re creating a new user I want to use fields_for to add a BillingAddress to the user like so: <%- fields_for :billing_address do |billing_address_form| -%> <%= render :partial
2006 Apr 04
4
Aggregating two objects of the same type
I would like to have a customer that has references to two addresses, a billing address and a shipping address. In a non-rails environment I would have two keys in the customers table, billing_address_id and shipping_address_id to reference the addresses. It appears that ActiveRecord expects the parent id to reside in the child table, regardless of whether the relationship is one-to-one or
2009 Mar 10
0
autosave no longer a valid option for belongs_to?
The Rails API doc (api.rubyonrails.org) says that :autosave is still a valid option for belongs_to in the latest version of Rails. However, a look at the activerecord/lib/active_record/associations.rb (line 1590) reveals that it is not in the @@valid_keys_for_belongs_to_association array. I also noticed that it''s not in the ActiveRecord API doc (ar.rubyonrails.org). Does anyone have any
2006 Apr 08
2
one-to-one relationship confusion
Hello, I posted a similar email, earlier in the week, but I still must not be getting it. I have a customer that aggregates two addresses; a shipping address and a billing address. Addresses can also be referenced by other objects in a similar way, so I would really like to avoid putting the keys referencing the customer or other objects in the addresses table. Addresses are exclusively
2009 Jan 15
4
HABTM and Check Boxes (Yet Another thread on this)....
Hi there, it''s an afternoon that i''m destroying my head on this, and i''ve decided to ask to you all . I''ve got to do some check box lists for a modified substruct version i''m doing, right now, i''m interested to insert a list of categories of interests into a customer sheet i''m using the substruct plugin version, wich stays in the
2006 Jul 30
3
ActiveRecord - Multiple Address for a single record
I''m trying to figure out the Rails way to model the following problem: I have 2 tables. One (let''s call it location) contains a single address. The other (let''s call it company) contains 3 address. I''m trying to figure out the best way to model this. I''ve created an address table, a set up the model as follows: class Address <
2005 Sep 29
0
Table relationships with single table inheritance
Hi, How do I relate a table to another when one of the models uses single table inheritance? Will this even work? This is the specific problem I am having: There''s an "Address" model with "ShippingAddress" and "BillingAddress" as subclasses. It looks like this: class Address < ActiveRecord::Base End class ShippingAddress < Address has_one :order
2007 Nov 21
0
Testing transactional updates in story runner
How do you guys test transactional updates with story runner? I have an action that needs to update four different models: Enrollment.transaction do @contact.update_addresses(params[:contact_address], params [:billing_address]) @enrollment.update_attributes!(params[:enrollment]) end The last update_attributes! will raise ActiveRecord::RecordNotValid if anything was
2006 Jul 21
3
How can I create OrderItems that go in a Order?
I suspect my problem is similar to having an order and wanting to have order items as part of the order, so I''ll explain the problem in those more familiar terms and then explain what if anything makes my actual situation different at the end. In an Order lets say you have: shipping_address and a shipped bool. OrderItem has quantity and name So Order has_many :OrderItems, and OrderItem
2006 May 04
22
Should controllers be "smart"?
I''m working on a small project with a friend, and one of the things we needed to do was send off an email whenever someone signs up an account. His implementation was pretty simple - throw a deliver_welcome call inside the controller after the signup. I''m sure that this is a pretty common thing to do. The problem, in my mind, was that the app now became tied to two places -
2006 Mar 24
0
A "virtual model" that encapsulates other models?
Hi, Is it possible to have a model in rails that does not exist as a database table by itself, but it exists solely by pulling data together from tables used by other models? For instance, let''s say I have a model of a "customer" which has_many "addresses", of which one of the "addresses" is the default address. So what I''d like to do is to