hi, im a new rails developper, and i try to create an action into a controller to do something like that: when u user purshase an item, his godparent (user contact) will receive money. i create the purshase controller it work fine, but i dont know how can i add this function. also, i had create a model to the commission: [code] id - user_id - contact_id - ammount - date [/code] the user model is like that: [code] id - user_name - ..... - contact - .... 1 - foo - ...... - Null - 2 - bar - ...... - foo [/code] in the purshase controller i have : [code] def create @purchase = Purchase.new(params[:purchase]) ...... respond_to do |format| if @purchase.save format.html { redirect_to @purchase, notice: ''La transaction a été créée.'' } format.json { render json: @purchase, status: :created, location: @purchase } else format.html { render action: [/code] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6b5e8a1d5e6bab89c57e5368ea52efd0%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
please can someone help me !! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/33369f55b0d0571210901eda26b391da%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
On Jul 15, 2013, at 6:28 AM, baby rails <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> please can someone help me !!Sadly, I cannot understand what it is you''re trying to do, or what help you are asking for.> hi, > im a new rails developper, and i try to create an action into a > controller to do something like that: > when u user purshase an item, his godparent (user contact) will receive > money. > i create the purshase controller it work fine, but i dont know how can i > add this function.Which function?> also, i had create a model to the commission: > [code] > id - user_id - contact_id - ammount - date > [/code] > the user model is like that: > [code] > id - user_name - ..... - contact - .... > 1 - foo - ...... - Null - > 2 - bar - ...... - foo > [/code]Use real code. Inventing something doesn''t actually help anyone figure out what is going on.> in the purshase controller i have : > [code] > def create > @purchase = Purchase.new(params[:purchase]) > ...... > > respond_to do |format| > if @purchase.save > > > > format.html { redirect_to @purchase, notice: ''La transaction a > été créée.'' } > format.json { render json: @purchase, status: :created, > location: @purchase } > else > format.html { render action: > [/code]-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/A310C139-42B4-4DB8-B8B3-E7044BCD26F8%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
thank you for reply: what i want to do is when a user C make a purchase, his godparent ( user B ) win some money and also the godparent of B ( user A). in the users table i come to add a column named "commission". so when B make purchase, B.commission += 1 and A.commission += 0.5 there''s a way to do this please. what code you want!? https://gist.github.com/anonymous/29ef897f922ad9878d4c -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3863495db714ff4381815eedbb8e0dea%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
On 15 July 2013 13:21, baby rails <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> hi, > im a new rails developperStart by working right through a good rails tutorial such as railstutorial.org. That will show you the basics of Rails. Then you will probably be able to answer your own question. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtqqrT1V5XpaSx%2BjAXXEMq-6rxXwEqRtAGE9OeB0f3HBA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.