Ruby on Rails: Entering data from another database into a new database

I have two databases in my app. One is Projects, that holds data on projects created in the app and another is User that I made when installing the Devise gem that holds the usernames and passwords of all the people that can use the app.

I have a page where the user can create a new project to be submitted into the database.

I am trying to get the :username field data of the current user from the User database to be submitted along with the data they enter to a new field called username_project.

<%= stylesheet_link_tag "form" %>


<%= form_for(@project) do |f| %>

<%= f.select( :username_project, User.all.map {|p| [p.:username]}) %>


<%= f.submit "Create New Project", :class => "button" %>


<% end %>

At the moment, there is a drop down that shows the Usernames stored in the database, but I am trying to get the <%= current_user.username %> value to be submitted as the username_project value, when the user hits submit. I am new to rails so go easy on me. Thanks in advance.

Update:

<%= stylesheet_link_tag "form" %>


    <%= form_for(@project) do |f| %>

<%= current_user.username %>
<%= f.hidden_field :username_project, :value => current_user.username %>

<%= f.submit "Create New Project", :class => "button" %>


    <% end %>

Answers


Use hidden_field helper:

<%= stylesheet_link_tag "form" %>

<%= form_for(@project) do |f| %>
  <%= f.hidden_field :username_project, :value => current_user.username %>
  <%= f.submit "Create New Project", :class => "button" %>
<% end %>

Need Your Help

sox cannot play files with a-law encoding

encoding sox

I am in linux mint 14 and trying to play a .sph file using sox with play foo.sph

Dynamic recordset populating textboxes

sql access-vba ms-access-2010 recordset

From a list of dates, I need to choose distinct dates, add 365 days, and then populate textboxes with each possible date.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.