On 16 August 2011 21:39, Angelo Cordova <acord...@gmail.com> wrote:
> The callback is not working. When I call to "Storage.create!" it
> should create a new Storage, but now the storage is never create.
>
> Thanks for your help, I'll try debugging.

Debugging will tell you whether the callback is being called.  If you
assign the result of Storage.create! to a variable and break after
that then you will be able to inspect that object.

Have you got any validations on Storage that could prevent it from saving?

Please don't top post, it makes it difficult to follow the thread.
Insert your reply at appropriate points in the previous message.
Thanks.

Colin

>
> On Aug 16, 3:58 pm, Colin Law <clan...@googlemail.com> wrote:
>> On 16 August 2011 17:40, Angelo Cordova <acord...@gmail.com> wrote:
>>
>> > Hello everyone
>>
>> > I have this model
>>
>> > class DetailPurchase < ActiveRecord::Base
>> >  belongs_to :purchase, :foreign_key => 'purchase_id'
>> >  belongs_to :product, :foreign_key => 'product_id'
>> >  belongs_to :buy_order_detail, :foreign_key => 'buy_detail_id'
>>
>> >  def before_create
>> >    Storage.create!(:product_id => self.product_id, :current_quantity
>> > => self.quantity, :stg_data => purchase.prc_data)
>>
>> Use ruby-debug to break in here and inspect the data to see what is
>> going on.  See the Rails Guide on debugging if you don't know how to
>> do this.
>>
>> >  end
>> > end
>>
>> > as you can see I'm using "before_create" callback. It was working just
>> > fine two weeks ago, but today I realize it wasn't. I don't know why.
>> > The only change is that now I'm using jquery instead of prototype
>>
>> You have not actually said what is not working.  Have you looked in
>> the rails log to see if there is anything of interest there?
>>
>> Colin
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to