For Mrperfect wrote:
First off, thanks for your reply. If it's the case the people haven't responded to my question for thinking that I haven't googled, I think think they're a bunch of stuck-ups!!!
It's also worth mentioning that your initial request and follow-up were within two hours of each other, in the middle of the night (for me). It's somewhat unreasonable to expect an answer in that timeframe, especially when the answer to your problem is actually in the official docs.
I did search but hadn't found my answer.
It's worth mentioning that, because the assumption otherwise will be that you haven't.
I even went through the trouble of signing up for an account, on here, just to ask this question!! I'm new to ruby.
I installed the activesupport gem but now I'm getting the error:
undefined method `execute'
I get the impression that this adapter is for ms sql server. would it work with mysql as well?
If you're using ActiveRecord (not sure why you need activesupport for this), then it's taken care of automatically. In any case, your problem isn't getting the last inserted ID, because this code:
customer = @asset.customers.build(params[:customer])
*doesn't* save the customer, according to the docs here:
ActiveRecord::Associations::ClassMethods.
You want a:
customer = @asset.customers.create(params[:customer])
following which, customer.id will have the ID of the customer record as inserted into the customers table.
···
--
Alex
Clifford Heath wrote:
For Mrperfect wrote:
It's not that, it's that no-one tends to respond quickly to folk who don't
bother to use Google. Look at the following link, and show the source of "insert":