# Save userform data in database

**URL:** <https://www.ruby-forum.com/t/save-userform-data-in-database/172897>\
**Category:** Rails\
**Created:** [July 29, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/save-userform-data-in-database/172897 "2009-07-29T16:27:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [July 29, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/save-userform-data-in-database/172897/1 "2009-07-29T16:27:12Z")

</div>

Hi,

I have a form like this.

\<% form\_for(@search) do |f| %\>  
\<%= f.error\_messages %\>

\<%= f.label :country %\>  
 \<%= f.text\_field :country %\>

\<%= f.label :city %\>  
 \<%= f.text\_field :city %\>

\<%= f.submit 'Search' %\>

\<% end %\>

When a user is login i want to store the searches of the form. So the  
user view recent searches.

Someone ideas/tips?

Grtz…remco

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [July 29, 2009, 8:25pm UTC](https://www.ruby-forum.com/t/save-userform-data-in-database/172897/2 "2009-07-29T20:25:56Z")

</div>

On Wed, Jul 29, 2009 at 7:27 AM, Remco  
Swoany[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> When a user is login i want to store the searches of the form. So the  
> user view recent searches.
> 
> Someone ideas/tips?

“saving data in a database” is pretty basic Rails. 🙂

Perhaps you could pose a more specific question?

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [July 29, 2009, 8:39pm UTC](https://www.ruby-forum.com/t/save-userform-data-in-database/172897/3 "2009-07-29T20:39:50Z")

</div>

Hassan S. wrote:

> On Wed, Jul 29, 2009 at 7:27 AM, Remco  
> Swoany[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > When a user is login i want to store the searches of the form. So the  
> > user view recent searches.
> > 
> > Someone ideas/tips?
> 
> “saving data in a database” is pretty basic Rails. 🙂
> 
> Perhaps you could pose a more specific question?
> 
> –  
> Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> twitter: @hassan

When a (login) user searches for a country or city and get the results,  
i want to store the user search-query in the database. The user can view  
their recent searches…if they are login…

remco

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [July 29, 2009, 8:50pm UTC](https://www.ruby-forum.com/t/save-userform-data-in-database/172897/4 "2009-07-29T20:50:31Z")

</div>

On Wed, Jul 29, 2009 at 11:39 AM, Remco  
Swoany[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> When a (login) user searches for a country or city and get the results,  
> i want to store the user search-query in the database. The user can view  
> their recent searches…if they are login…

OK, sounds pretty straightforward.

User, Search, user has\_many searches – what’s the issue?

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan
