similar to: Fwd: Re: Mocha and ActiveRecord

Displaying 20 results from an estimated 200 matches similar to: "Fwd: Re: Mocha and ActiveRecord"

2006 May 26
4
Using ''validates_inclusion_of'' to validate foreign key
I seem to be missing something trying to use ''validates_inclusion_of'' to validate a foreign key and was hoping some one could piont out my mistake? The problem seems to be that Order.find_all.collect is not returning an array that contains the order_id, if I replace it with a hardcoded array everything works as expected. The model: class OrderItem < ActiveRecord::Base
2006 Mar 14
5
GROUP BY and SUM
I have orders, order_items, and products. I want to collate several orders so that I can get a SUM of quantities ordered for each product etc. Can I say something like (the below gives an error on :sum, and ignores :group) OrderItem.find(:all, :sum => ''quantity'', :group => ''product_id'', :include => [:order, :product]) I want to get back a
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
2010 Sep 08
4
Re-using Rspec Matchers
Hey Everyone, Is it good practice to call matchers from within matchers? Kinda like this pattern: See: http://gist.github.com/570467 -- Brian
2008 Jun 04
2
Mock with an attributes that has state
I''m developing a rails application. I have an Order model that has_many OrderItems. I mocked the OrderItem model in my Order specs using mock_model. I thought I should focus my specs on each model and always mock associated models. In my Order model I need a way to merge OrderItems which have the same cost and same product_id. That I can spec. The other thing this merge helper
2006 Mar 13
8
Nested find(:all, :include => ) statements
Is there a way for me to do: OrderItem.find(:all, :include => [:user, :product => [:supplier]] So I don''t have a supplier_id on my order_item, but have it on my product, which is part of order_item. Joerg -- Posted via http://www.ruby-forum.com/.
2005 Dec 25
2
[repost] newbie questions
Hi all, I''m following the shop example in ''Agile Web Development with Rails''. I would like to extend the checkout screen, in such a way people can change the number of items they have selected in there cart. In my controller I have: def checkout @cart = find_cart @items = @cart.items if @items.empty?
2005 Dec 23
0
newbie question
Hi all, I''m following the shop example in ''Agile Web Development with Rails''. I would like to extend the checkout screen, in such a way people can change the number of items they have selected in there cart. In my controller I have: def checkout @cart = find_cart @items = @cart.items if @items.empty?
2006 Feb 20
0
YAML and has many associations
Hi, I have the following: order = YAML::load(order_yaml) The YAML contains order_items too, and my order model has a has_many to order_items. When I do order.order_items, I don''t want Rails to go the db to get the order_items, but use the order_items already contained in the object created from the YAML. How would I do this? Thanks Joerg -- Posted via
2006 Jul 11
0
using acts_as_list storing the information in a session
Hi, I have an order model that i am storing in a session, that is not currently in the database. I am updating the page using ajax, and I do not want to store the order in the database untill it is completely filled out. I have order_items that I am adding to the order, and I have used the acts_as_list within the order_item model. My problem comes when i try and rearrange the order_items
2005 Apr 13
2
Creating multiple option groups
I''m setting up a basic shopping cart type app, and the products we have will have multiple options. Size, color, etc. I''m trying to figure out how I can collect the the options that are selected when a user adds the item to their cart. An OptionSet is a group of options ("Size", "Color", etc), and an ItemOption is the option itself ("12 oz",
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
2004 Nov 30
1
RE: question about rails regarding handling more than onetable in one view
Hi, Jarkko: Thanks for the quick reply. I understand I can use ActiveRecord to specify the relation between the table as you have suggested, The part that I have trouble to understand is 1. Since I have a third table ProvWorkAtDept, do I need to specify this table somewhere when I define Provider or Dept? 2. If the provider view has both the provider name and several depts the provider
2006 Jul 29
0
SOAP for large datasets
I''ve been playing around with a soap interface to an application that can return large datasets (up to 50mb or so). There are also some nested structures for which I''ve used ActionWebService::Struct with 2-3 nested members of oher ActionWebService::Struct members. In addition to chewing up a ton of memory, cpu ulilization isn''t that great either. My development
2006 May 28
0
expanding details examples?
I''m currently using page.visual_effect :toggle_appear to toggle the appearance of details associated with an order. As I am inserting the detail data prior to making it visible, this method is not appropriate (it also loads the data on hide). I was thinking I could change the hide/show href each time it is clicked, or even store a value on the page and toggle it each time
2006 Apr 20
2
Additional Fields in a Join Table
Hi, I am creating an order management web application, and have run into an issue over join tables. I am reading Agile Web Development and it says that I can put additional fields within my join tables, and they give the example of a date field. I want to know if it is possible to do the following: I have an orders table with the order information as well as an orders_items table and an
2006 Sep 08
1
testing question
ok, i''ve written a couple of unit tests and it was pretty straight forward as far as what i should and shouldn''t be testing in the unit test.. until now. i am testing a customer model right now.. i figure that a unit test should test the functions of a model as well as if you can do all the crud stuff and validations. right now i wish to test a customer model function that
2006 Apr 14
3
Updateform with a has_many relationship ?
Hello all, I would like to be able to update the "amount" of a certain item in me order list. The problem I run into is how to define the text_field element. @order is the current order, which has_many :order_item which in turn belongs_to :order. order_item has a field "amount" which should be modified... What I tried is this below, but I get a undefined method
2009 Oct 14
14
spec-ing private methods?
On Wed, Oct 14, 2009 at 5:49 PM, Scott Taylor <scott at railsnewbie.com> wrote: > > On Oct 14, 2009, at 3:36 PM, Joaquin Rivera Padron wrote: > > hello there, > how do you tipically spec private methods? The thing is ? have something > like this: > > def some_method > ?? complex_method + other_complex_methods > end > > private > def complex_method...
2007 Jun 15
0
Fwd: [ mocha-Patches-11583 ] Mocha 0.5.0 throwing unexpected warnings, one line patch included
Begin forwarded message: > From: <noreply at rubyforge.org> > Date: 15 June 2007 10:44:07 BDT > To: noreply at rubyforge.org > Subject: [ mocha-Patches-11583 ] Mocha 0.5.0 throwing unexpected > warnings, one line patch included > > Patches item #11583, was opened at 2007-06-14 21:28 > You can respond by visiting: > http://rubyforge.org/tracker/? >