Hi,

Is there any way to insert data when form is saved into another table.

Say for example:

I have membership table which already contains some data and have column
names as 'no_of_users_added', 'no_of_users_left'.

I want to insert data from user table based on the count value how many
users are saved and the corresponding column values ('no_of_users_added'
and 'no_of_users_left') gets updated into the Membership table.

Please help me resolving this issue.

Regards,
Milley

--
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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bbbd03f337a39a3a8c572e8bc65a5bdd%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Elizabeth McGurty at Aug 21, 2015 at 11:24 am
    Look at http://api.rubyonrails.org/classes/ActiveModel/Dirty.html,
    specifically method changed? at
    http://api.rubyonrails.org/classes/ActiveModel/Dirty.html, and
    http://apidock.com/rails/ActiveRecord/Dirty/changed
    On Friday, August 21, 2015 at 6:47:15 AM UTC-4, Ruby-Forum.com User wrote:

    Hi,

    Is there any way to insert data when form is saved into another table.

    Say for example:

    I have membership table which already contains some data and have column
    names as 'no_of_users_added', 'no_of_users_left'.

    I want to insert data from user table based on the count value how many
    users are saved and the corresponding column values ('no_of_users_added'
    and 'no_of_users_left') gets updated into the Membership table.

    Please help me resolving this issue.

    Regards,
    Milley

    --
    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@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f9a7eb00-7397-4ac1-b8df-e121448117c4%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colin Law at Aug 21, 2015 at 9:01 pm

    On 21 August 2015 at 11:46, Milley Duke wrote:
    Hi,

    Is there any way to insert data when form is saved into another table.

    Say for example:

    I have membership table which already contains some data and have column
    names as 'no_of_users_added', 'no_of_users_left'.

    I want to insert data from user table based on the count value how many
    users are saved and the corresponding column values ('no_of_users_added'
    and 'no_of_users_left') gets updated into the Membership table.
    You can write records to any table you like from any controller. So
    to add a new record just use ModelName.new, set the values as
    appropriate and save it. However generally it is bad practice to save
    anything that can be calculated on the fly, and I rather suspect that
    at least one of the values you mention may fall into that category,
    posibly both. You may think it is a worthwhile efficiency saving but
    the bottlenecks in an app are very rarely where you expect them to be.
    There are many issues to be thought about when saving data that can be
    calculated. Suppose for example the server crashes at an unfortunate
    moment such that you end up with the saved value not representing the
    calculated value.

    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@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs9TOztAL5myZnZciimQt7iGQS1g0n4eWRshe9kFPN3Ow%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedAug 21, '15 at 10:46a
activeAug 21, '15 at 9:01p
posts3
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase