similar to: how can I control when to commit a transaction?

Displaying 20 results from an estimated 100 matches similar to: "how can I control when to commit a transaction?"

2007 Nov 20
2
confirming that a model instance was correctly created from POST params
I''m wondering whether I''m wasting my time trying to verify that an addition I''ve made to legacy code is in fact setting a new attribute on a model. Substruct''s (http://dev.subimage.com/projects/substruct) OrderHelper contains this method: 1 def create_order_from_post 2 @use_separate_shipping_address = params[:use_separate_shipping_address]
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
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
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
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:
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 -
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
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 Aug 10
6
save without commit ?
How do I get ''save'' to execute without commit? I have tried: ActiveRecord::Base.connection.begin_db_transaction # do some stuff that doesn''t issue a database COMMIT statement # then: @myObject.save # this issues a COMMIT but it shouldn''t! Shouldn''t it wait until I''ve called: ActiveRecord::Base.connection.commit_db_transaction ? what am
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 <
2006 May 10
8
dynamic setting of username and password in database.yml
Hello I''ve now read a lot about application-level authentication in Rails, but I need to do database-level authentication. The reason is that my database needs to have the current_user (database current_user, not current_user defined in an ActiveRecord Model) set to execute triggers for automatically updating audit tables. So it is not enough to have a session check against a User
2006 Jun 01
2
update_all broken in postgres?
Hi has anyone managed to use update_all with rails on postgres? In my setup, it does not work: >> @keyword.update_all(myupdates) NoMethodError: undefined method `update_all'' for #<Keyword:0xb7ac4670> from /home/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1786:in `method_missing'' from (irb):14 I checked that the base.rb
2006 Jun 01
4
Ruby on Rails strange issue
Hello, I just installed Ruby on Rails and created the new repository. I wanted to use Ruby on Rails with FCGI The repository was created in /path/to/public_html ls /path/to/public_html/ : app cgi-bin config doc log public README script tmp asd components db lib logo.jpg Rakefile README_LOGIN test vendor I installed fcgi support for ruby on rails and
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 Mar 08
2
where is version1.1
installed latest rails from gems.rubyonrails.org it says its installing rails-1.0.0.3801 how do I get rails-1.1 ? -- Posted via http://www.ruby-forum.com/.
2006 Mar 08
3
Namespace & Organisation Conventions
Hi All I wanted a little advice on the convention for namespace usage and organisation of code. I originally used PHP and often had an "admin" backend that performed the various admin tasks with users, and data Then I had a front-end often situated at the root that had user services. I''m trying to emulate this in Rails but feel I''m missing a significant point here and
2006 Apr 07
2
errors.add_to_base
What are the limitations on using: errors.add_to_base to display errors in views? I have tried for days to add errors from my object.rb and they never get displayed. class Keyword < ActiveRecord::Base validates_presence_of(:name, :message => "Name is required.") validates_uniqueness_of(:name, :message => "This name is already in use. Please try
2006 Mar 07
2
webrick RoutingError
problem: webrick will start a rails server, but I cannot access my application. I get the error: Processing Base#index (for 127.0.0.1 at Tue Mar 07 19:16:58 CET 2006) Parameters: {} ActionController::RoutingError (Recognition failed for "/keywordeditor"): my application is called keywordeditor. I am starting the server from the correct place with the correct command (I already
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
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