Wai T. wrote:
Tony M. wrote:
What I would like to do at this point is copy a few
attributes(lname, fname, signature, phone) to a table called receipts?
I’ve already created a relationship between addpackages and receipts, I
just need help with coding behind this operation. I figure I would
perform this operation in the addpackage controller under “def edit” but
I really need a kick start to coding this or someone to tell me this is
the correct way to do it.
It would really help if you could give us the relationships between the
models. From my understanding, you are trying to copy the fields from
one table to another right? In that case, you can look up the package
record in the receipt model and copy the attributes to the current
records.
I think we are on the same page, but here’s a visual representation just
in case.
1: The ID# is clicked when a user comes to the mailroom to get their
package
http://aycu34.webshots.com/image/15313/2002794410554314194_rs.jpg
2: The app will prompt for the users initials
http://aycu24.webshots.com/image/15343/2002700669700389807_rs.jpg
3: Upon clicking the Sign for package, the initials/date are logged, and
what I want to happen is to copy all all fields needed to fill this
following Receipts table, and at the same time delete the selected
record from Inventory, as the package has been picked up and it is no
longer in the mailroom.
http://aycu01.webshots.com/image/13400/2002736555382712550_rs.jpg
Here are my relations at the moment:
class Addpackage < ActiveRecord::Base
belongs_to :category
has_and_belongs_to_many :rosters
has_many :receipts
end
class Receipt < ActiveRecord::Base
has_and_belongs_to_many :addpackages
end
I’ve been trying to do this operation from both the addpackage
controller and receipt controller but have failed. I’m still a newbie
to rails so it might just be my syntax or incomplete knowledge. You
said above I could perform all these operations from receipt.db model?
I have never put anything but relations in those.
Anyway I have exhausted myself trying to get this to work. I’ll keep
hacking at it, but im not getting much of anywhere.