Update column value

18 views
Skip to first unread message

Milley Duke

unread,
Aug 24, 2015, 6:00:14 AM8/24/15
to rubyonra...@googlegroups.com
Hi,

Is there any way that I can Update column value of another table when
saving form data of another model.

For example:

I have two models model A and model B. Both of them have one to many
relation with each other.

On filling data in form fields of model B , when particular condition
met, i want to update the column value of model A.

--
Posted via http://www.ruby-forum.com/.

Elizabeth McGurty

unread,
Aug 24, 2015, 12:33:27 PM8/24/15
to Ruby on Rails: Talk
Both model A and model B have a one-to-many relationship.  Seems to me that you have not done your homework.

There is a huge abundance of information on the web to understand Ruby and Ruby on Rails.  Research: Rails models associations

Liz 

Colin Law

unread,
Aug 24, 2015, 4:39:38 PM8/24/15
to Ruby on Rails: Talk
On 24 August 2015 at 10:59, Milley Duke <li...@ruby-forum.com> wrote:
> Hi,
>
> Is there any way that I can Update column value of another table when
> saving form data of another model.
>
> For example:
>
> I have two models model A and model B. Both of them have one to many
> relation with each other.
>
> On filling data in form fields of model B , when particular condition
> met, i want to update the column value of model A.

As I explained when you first asked this problem you can write to
records in any table you like in any controller. Simple find the
record you want, update the value and save it. I note you did not
reply to the help offered by Elizabeth or myself in that case.

Also, as Elizabeth suggested, I think perhaps you have missed some of
the basic concepts of Rails and suggest that working right through a
good tutorial such as railstutorial.org (which is free to use online)
would help you and save you a lot of time in the long run.

Colin
Reply all
Reply to author
Forward
0 new messages