<%= text_field %> - how to set the value to session name?


#1

I’m trying to automatically fill a “posted_by” text by with whoever is
logged into the session. How do you set the value attribute using “<%=
text_field … %>”???

I’ve tried:

<%= text_field ‘post’, ‘posted_by’, ‘value’ =>
User.find(session[:user_id]).name.capitalize) %>

But I get errors.

If someone can tell me how to do this simple thing, I would really
appreciate it! Thanks!


#2

To make your method work:

<%= text_field ‘post’, ‘posted_by’, :value =>
User.find(session[:user_id]).name.capitalize) %>

On 5/8/06, rh removed_email_address@domain.invalid wrote:

If someone can tell me how to do this simple thing, I would really
appreciate it! Thanks!


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


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Ben R.
303-947-0446
http://www.benr75.com


#3

try:
<%= text_field ‘post’, ‘posted_by’,
User.find(session[:user_id]).name.capitalize)
%>


#4

Why not store session[:user_id] in the posted_by field?

~ Ben

On 5/8/06, rh removed_email_address@domain.invalid wrote:

If someone can tell me how to do this simple thing, I would really
appreciate it! Thanks!


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


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Ben R.
303-947-0446
http://www.benr75.com


#5

Thanks everyone, it works now.