# CRUD data entry of a foreign key

**URL:** <https://www.ruby-forum.com/t/crud-data-entry-of-a-foreign-key/128571>\
**Category:** Rails\
**Created:** [February 8, 2008, 11:28pm UTC](https://www.ruby-forum.com/t/crud-data-entry-of-a-foreign-key/128571 "2008-02-08T23:28:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 8, 2008, 11:28pm UTC](https://www.ruby-forum.com/t/crud-data-entry-of-a-foreign-key/128571/1 "2008-02-08T23:28:43Z")

</div>

I can change the foreign key for a row in the “calls” table through the  
console, but want to be able to assign a different login\_id to a  
specific  
“calls” record.

This is done through the controller and the view?

thufir@arrakis ~/goodfellow-tool $  
thufir@arrakis ~/goodfellow-tool $ script/console  
Loading development environment.

> > c=Call.find\_by\_id(1)  
> > =\> #\<Call:0xb6fc9070 @attributes={“id”=\>“1”, “comment”=\>“first”,  
> > “login\_id”=\>“1”, “created\_at”=\>“2008-02-08 13:37:29”}\>
> 
> >

?\> l=Login.find\_by\_id(2)  
=\> #\<Login:0xb6fb8fb8 @attributes={“id”=\>“2”, “employee\_id”=\>“1”,  
“login”=\>“1234”}\>

> >

?\> c.update\_attribute :login\_id, 2  
=\> true

> >

?\> c  
=\> #\<Call:0xb6fc9070 @attributes={“id”=\>“1”, “comment”=\>“first”,  
“login\_id”=\>2, “created\_at”=\>“2008-02-08 13:37:29”}\>

> >

?\> quit  
thufir@arrakis ~/goodfellow-tool $
