Displaying 20 results from an estimated 10000 matches similar to: "Problem with the association."
2005 Dec 23
0
adding items to a particular invoice on the same page
Hi,
I have been building a invoice generator(in ruby on rails) for the
past some days and been stuck on the final page .This page will have fields
for entering the invoice details and also I have added a AJAX effect so that
fields for invoice items get created dynamically . its all design well but
the issue comes when I am trying to save the page .That is adding ivoice
details to invoices
2007 Aug 13
0
Invoice system
Hi,
I wanna make a invoice system. I''ve set up a invoice model and a
invoice_item model (invoice has_many invoice_item and invoice_item
belongs_to invoice). Also invoice belongs_to a customer, and a customer
has_many invoice.
My problem is i don''t know how to create the form for making a new
invoice. I''ve made a similar system in php, and here is how the html
form was:
2007 Sep 05
8
Hi..Guys new plugin again
Hi..
Guys new plugin again
Foreign Key Associations is a plugin that automatically creates
associations based on foreign-keys. The associations are created at
runtime-ie. as your ActiveRecord models are loaded-so they will always
be up-to-date.
For example, given a foreign-key from a customer_id column in an
orders table to an id column in a customers table, the plugin
creates:
2006 Jun 20
1
ActiveRecord saving madness?
Hello,
First of all, I love RoR. I am studying it, and I am finally "getting
there".
However, I do have a bit of a problem with ActiveRecord''s saving
behaviour.
Imagine to have Orders (id, name) {has_one:invoice} and Invoices (id,
order_id) {belongs_to :order} .
If you type:
invoice = Invoice.new(...whatever...)
an_order.invoice = invoice
if invoice fails to save, you
2007 Nov 29
3
Strange Array behaviour
I''m having a strange thing when using the Enumerable extensions for
Rails:
Have a look at the following code:
class Invoice < ActiveRecord::Base
has_many :invoice_lines
def total
invoice_lines.sum(&:total)
end
end
class InvoiceLine < ActiveRecord::Base
belongs_to :invoice
def total
amount * price
end
end
Now, when calling invoice.total, I get wrong
2011 Jan 11
0
[PATCH] Polymorphic belongs_to association with :conditions issues
Hey all,
Could use a few eyes on a couple of very simple patches at https://rails.lighthouseapp.com/projects/8994/tickets/6262 if any has some time.
The issue (from the ticket description):
If you define a polymorphic belongs_to association and it has conditions on it, those conditions cause a NameError when you try to access the target object, of the style saying "hey, there''s no
2008 Jan 30
0
Plugin belongs_to Model Association Bug
Hey all,
I''m not positive if this is a Engines bug, but it seems very peculiar
and a few hours of Googling haven''t given me any good leads yet, so I
thought I''d see if it makes sense to any of you:
I am writing a new version of the savage_beast plugin (implements
Beast forums as a plugin) that''s Rails 2.0 compatible, and I am having
trouble with the many
2006 Mar 15
1
An Association Problem: AR::Base.find{:include} and n-deep association traversal
Dear List,
I''m using Edge Rails.
I have a Model with Items for purchase. Each Item is of a certain brand.
Class Brand < ActiveRecord::Base
end
Class Item < ActiveRecord::Base
belongs_to :brand
end
The problem domain is that I''d like to create a separate Inventory
list of Items. This includes the date of entry into inventory and
date of exit from inventory (ie
2006 Jul 31
2
Updating a belongs_to foreign key leaves the old association object available
Perhaps this is intentional, but it seems unlikely:
class Person < ActiveRecord::Base
belongs_to :school
end
p = Person.find(:first)
p.school # nil
p.school_id = School.find_by_name(''High School'').id
p.school.name # High School
p.school_id = School.find_by_name(''Primary School'').id
p.school.name # High School <= Shouldn''t this be Primary
2006 May 05
0
Missing documentation for find_in_collection? Trying to drill down in a 4 level has_many association fails
I''ve been reading up in ActiveRecord::Associations and playing around
with my app via the console and found some interesting methods via
the code completion of IRB, but I have no idea how to use them and
can only find one hint in the API
http://api.rubyonrails.com/classes/ActiveRecord/Associations/
ClassMethods.html
It mentions here in the has many associations that if you use the
2009 Nov 01
1
please help - complicated polymorphic association
I am trying to build a shared-appointment system, where users can
subscribe to appointments and be updated whenever changes are made to
them. I have three objects in this system, appointments, users, and
subscribers. Subscribers are a polymorphic object like so:
class Subscriber < ActiveRecord::Base
belongs_to :user
belongs_to :subscribable, :polymorphic => true
end
The tricky part is
2008 Feb 13
1
can a class have the association has_itself?
is it possible to implement a recursive foreign key association like
that?
i''m writing a vocab app, where i want the vocab table to have an id
and two foreign keys, word1 and word2.
the word table will have an id, a word-string, and a language
i''m trying to do this as follows:
class Vocab < ActiveRecord::Base
belongs_to :word
belongs_to :word
class Word <
2009 Apr 16
0
Magic multi connections with association problem
Dear all
I am using magic multi connections, there is some problem when using
association. How can I dynamic determine the module name (i.e.
A::Request, B::Request) in activerecord association.
Below is my code:
module A
establish_connection :A
end
module B
establish_connection :B
end
# and many module....
class Request < ActiveRecord::Base
set_table_name "request"
2008 May 07
1
Assigning to the foreign key on a belongs_to association
I''ve encountered what seems like an odd omission in the behaviour of
belongs_to associations: if you assign to the foreign key attribute,
it doesn''t update the associated object (or mark a previously loaded
one as stale) until you explicitly save or reload it.
Let''s say we have a Company model, which belongs_to :city :
>> torchbox =
2006 Jun 19
2
const_missing error of has_many through association
Hi,
I am new to ruby on rails. I am building an association join model
and encountered the following error. Does anyone know what am I
missing?
> NameError in StartController#home
>
>d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:100:in `const_missing'': uninitialized constant Membership
I have the following tables relationships
Users
2009 Aug 10
1
Call AR belongs_to association accessor ID method on object assignment
Hi,
Haven''t been able to find this raised before but I''m sure it must have
been. When assigning an object to a belongs_to association I would
like it to call the *association*_id= method instead of directly
updating the attributes array. This is because I want to modify the
behaviour when assigning a particular object without writing separate
methods for whether it''s
2012 Jan 18
2
Polymorphic and standard association issue
Hello all,
I''m having a strange issue with a model that belongs_to two other
models. The one association is polymorphic and the other is normal.
================================
class Role < ActiveRecord::Base
belongs_to :user
belongs_to :permission, :polymorphic => true
end
class User < ActiveRecord::Base
has_many :roles
has_many :programs, :through => :roles
end
2006 Feb 14
0
Help with Eager Association
I''ve gotten eager associations to work before, but for some reason
this isn''t working out for me this time. I''ve been scratching my head
but can''t quite figure out the nuances of what works and what doesn''t
work.
I''ve got 3 models: profile, widget_configuration and widgets
profile.rb --
has_many :widget_configurations
2007 Jul 17
0
Multiple inserts on a through association.
class Trunk < ActiveRecord::Base
has_many :call_type_trunks
has_many :call_types, :through => :call_type_trunks
end
class CallType < ActiveRecord::Base
has_many :call_type_trunks
has_many :trunks, :through => :call_type_trunks
end
class CallTypeTrunk < ActiveRecord::Base
belongs_to :call_type
belongs_to :trunk
end
The associaton class has a column named price.
2006 Jan 25
1
Rails day 2: where is my association?
I?m following along a few tutorials on the web and trying to implement
my own example, but I must be missing something because I can?t get
has_many or belongs_to to work like I expected. now I have watched all
the videos and made a cookbook several times with different interfaces.
what I''m looking for is *not* a code snippet to solve something (because
I already have that),