Displaying 20 results from an estimated 4000 matches similar to: "Additional Fields in a Join Table"
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
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
2006 Jan 25
2
Update join_table attributes
I have two ActiveRecord classes that point at each other with a
"has_and_belongs_to_many" (habtm) relationship using a join table. The
join
table has an a few additional columns besides the _id columns.
For those of you with the Agile Web Dev w/ Rails book, it''s exactly the
same
setup as the articles<->articles_users<->users example on p240.
The habtm
2006 Jul 06
7
form_remote_tag submitting to an rjs file.
I have the following form that I am trying to use, but for some reason,
the form gets submitted with out the params values.
<%= form_remote_tag(:url => { :action => :add_item_to_order }) %>
<tr>
<td>
<%=collection_select(:order_item , :item_category_id,
@item_categories, :id, :name)%>
</td>
<td>
<%= text_field
2006 Jul 05
7
HABTM join table has an "ID" column - is this an issue?
All,
I''m building model objects for existing tables that I cannot modify.
In AWDWR, Dave says "Note that our join table has no id column...The
second reason for not including an id column in the join table is that
AR automatically includes all columns from the join tables when
accessing rows using it. If the join table included a column called id,
its id would overwrite the id
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
2006 Apr 16
5
Newbie Problems with pluralization
Hi,
I have a many to many relationship incorporating the following tables:
taxes --> taxes_tax_groups --> tax_groups
I have a model named tax with the following declaration:
has_and_belongs_to_many :tax_groups
and I have a model named tax_group with the following declaration:
has_and_belongs_to_many :taxes
I am attempting to run the following unit test:
require
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 Dec 02
0
Fwd: Re: Mocha and ActiveRecord
---------- Forwarded message ----------
From: J. B. Rainsberger <jbrains762 at gmail.com>
Date: 02-Dec-2006 02:48
Subject: Re: Mocha and ActiveRecord
To: ruby-talk ML <ruby-talk at ruby-lang.org>
James Mead wrote:
> On 28/11/06, J. B. Rainsberger <jbrains762 at gmail.com> wrote:
>>
>> Suppose I have an Order, which has_many OrderItems. Suppose I want to
>>
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 May 11
1
ActiveRecord collection_select and has_and_belongs_to_many
Hello everyone, first post to the list and a relative newbie to Rails
development. Done quite a bit of JSP, PHP, HTML, XML etc and thought I would
kick the tires on Rails to see if it can speed up development for internal
applications. Anyway, I am running into a problem that is just driving me
crazy and everything I read on the net doesn''t seem to help. I was hoping
someone here might
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
2006 May 06
3
Storing additional data on join tables with Rails
Hi there
I need to store additional attributes on join table. Searching the
Wiki [1] revealed two possible methods:
1) push_with_attributes, as described by Justin Palmer [2].
Unfortunately, "this method is now deprecated" [3]. Even if it wasn''t,
there seem to be inherent problems with that approach, for example
with updating those additional attributes, though Joshua Muheim
2006 Apr 03
1
:through causes White Screen of Death
i''m trying to get :through associations working per the wiki:
http://wiki.rubyonrails.com/rails/pages/ThroughAssociations
i follow the instruction to the t, with the exception that i''m trying to use it
with a polymorphic association. here are the associations in my models:
Collection has_many :collectings
Collection has_many :collectables, :through => collectings
Collecting
2006 Apr 28
2
Ajax form error handling
Hi,
I have a customer add form in which i call form_remote_tag to update a
customer list within another div on my page.
I need to also, however, allow for proper error checking, and the issue
is that the form_remote_tag will only update a single div tag.
I have seen a few ways to deal with this, but I want to know what the
best way is, while still allowing the model to do all of the
2006 Jun 05
7
Is HABTM Dying?
For a while, I''ve been getting that HMT is replacing HABTM. It appears that
HMT can do all of what HABTM can do and more. The question is: Should I stop
using HABTM? Let''s take a simple case:
A case has many categories
For a given category, there are certain valid statuses
Category
has_and_belongs_to_many :statuses
Status
has_and_belongs_to_many :categories
Question:
Is
2006 Jul 10
7
What is has_many :through really buying you over HABTM?
So having just learned how to do has_many :through as opposed to HABTM,
and then, being concerned that I wouldn''t get it to work, I started
thinking about these two approaches.
It seems to me that the _only_ problem that the HM:T (has_many :through)
approach solves that HABTM doesn''t is the issue of the potential
collision of id columns between your join table and one of
2006 May 30
3
extra attributes in habtm
Hi,
Posting here since issue tracking isn''t the best place to discuss.
I can understand habtm is moving towards deprecating support for extra
attributes in join_table, and to use :through for those cases instead.
To clarify, patch<http://dev.rubyonrails.org/attachment/ticket/5216/habtm_join_table_test.patch1.diff>for
#5216 <http://dev.rubyonrails.org/ticket/5216>
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