rh
2006-May-08 19:10 UTC
[Rails] <%= text_field %> - how to set the value to session name?
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! -- Posted via http://www.ruby-forum.com/.
Rob Merrell
2006-May-08 19:14 UTC
[Rails] <%= text_field %> - how to set the value to session name?
try: <%= text_field ''post'', ''posted_by'', User.find(session[:user_id]).name.capitalize) %> On 5/8/06, rh <rheath@ircwv.com> wrote:> > 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! > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- c++: the power, elegance and simplicity of a hand grenade http://www.migrob.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060508/e7402671/attachment.html
Ben Reubenstein
2006-May-08 19:15 UTC
[Rails] <%= text_field %> - how to set the value to session name?
Why not store session[:user_id] in the posted_by field? ~ Ben On 5/8/06, rh <rheath@ircwv.com> wrote:> 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! > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein 303-947-0446 http://www.benr75.com
Ben Reubenstein
2006-May-08 19:27 UTC
[Rails] <%= text_field %> - how to set the value to session name?
To make your method work: <%= text_field ''post'', ''posted_by'', :value => User.find(session[:user_id]).name.capitalize) %> On 5/8/06, rh <rheath@ircwv.com> wrote:> 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! > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein 303-947-0446 http://www.benr75.com