I have been working on this small, minute, part on my project and it all hinges on setting the value in a text_field helper. Saying: <%= text_field ''user'', ''company'', :value => @login %> does not do it. When I go and look at the raw html, there is no value there and "value" is an attribute of the input tag, im pretty sure. I really like RoR and how things work, but they fail miserably when it comes to documentation. Anybody know of any good reference sites besides http://api.rubyonrails.org/? Thanks, ~S -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
the text_field helper expects the first parameter to be an instance variable. The second parameter is the method that will be called on the instance variable to populate the value of the text field. So if you have the following: controller.rb def new @user = User.new(params[:user]) end view.rhtml <%= text_field :user, :first_name %> the field will contain the value of the user''s first name (providing that you have a "first_name" attribute in your users table in your database). If the user doesn''t have a first name (ie the record is new), then the value will be blank. If you want more control about how the text field''s value is populated, you can use the following: text_field_tag ''name of text field'', @value you should read through Agile Web Development for Rails if you haven''t done so already.. This type of stuff is outlined in the book. Adam On 7/20/07, Shandy Nantz <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have been working on this small, minute, part on my project and it all > hinges on setting the value in a text_field helper. Saying: > > <%= text_field ''user'', ''company'', :value => @login %> > > does not do it. When I go and look at the raw html, there is no value > there and "value" is an attribute of the input tag, im pretty sure. I > really like RoR and how things work, but they fail miserably when it > comes to documentation. Anybody know of any good reference sites besides > http://api.rubyonrails.org/? Thanks, > > ~S > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yeah, it works, to a point. My issue is that you start out at a "traveler_form.rhtml." On submit, the :action ''create_user'' is performed and when the log-in fails a redirect_to reloads the traveler_form. But before that, the controller for the traveler_form, the ''traveler_form'' method gets called, correct? At least this is the way that I understand the flow of data in the program. The information basically is getting lost in this loop. I''m just trying to figure out what I''m missing or not understanding? Thanks ~S -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
simply don''t use a redirect, but render :action => :traveler_form On 21 Jul., 00:13, Shandy Nantz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Yeah, it works, to a point. My issue is that you start out at a > "traveler_form.rhtml." On submit, the :action ''create_user'' is performed > and when the log-in fails a redirect_to reloads the traveler_form. But > before that, the controller for the traveler_form, the ''traveler_form'' > method gets called, correct? At least this is the way that I understand > the flow of data in the program. The information basically is getting > lost in this loop. I''m just trying to figure out what I''m missing or not > understanding? Thanks > > ~S > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, I have a similar problem: I need to: 1. put a ''reset'' button so that I can clear (set to blank) the text_field when the user clicks on the button and 2. retain value in text_field: I have a ''search'' button that performs search (not Ajax livesearch... it''s a simple search and I wrote the code in my controller). Now, when the user puts some text (query) in the text_field and clicks on ''search'', the results are shown ok, but I need to retain the text in the text-field that the user put in. Also I need to set the focus to this text_field after the results are shown. The relevant code in the view is: <%= start_form_tag :action => ''search''%> <%= text_field :server, :server_name, :size => 15 %> <%= submit_tag ''Search'' %> <%= end_form_tag %> <%= set_focus_to_id ''server_server_name'' %> The controller code for ''search'' is: def search condition = "" var = "" if !params[:server][:server_name].blank? column_query = params[:server][:server_name] var = params[:server][:server_name] condition_part = "lower(s.server_name) like \''%" + column_query.downcase + "%\''" condition = condition + condition_part and_flag = 1 end ... if !condition.blank? sql = " select s.server_name, s.server_type_code from server s where " + "#{condition}" ... @server_pages, @servers = paginate_by_sql Server, sql, 30 render :partial => "search", :layout => "application" Your help would be greatly appreciated. Thanks. On Jul 20, 3:07 pm, "Adam Cohen" <bionicboo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> the text_field helper expects the first parameter to be an instance > variable. The second parameter is the method that will be called on > the instance variable to populate the value of the text field. So if > you have the following: > > controller.rb > > def new > @user = User.new(params[:user]) > end > > view.rhtml > > <%= text_field :user, :first_name %> > > the field will contain the value of the user''s first name (providing > that you have a "first_name" attribute in your users table in your > database). If the user doesn''t have a first name (ie the record is > new), then the value will be blank. > > If you want more control about how the text field''s value is > populated, you can use the following: > > text_field_tag ''name of text field'', @value > > you should read through Agile Web Development for Rails if you haven''t > done so already.. This type of stuff is outlined in the book. > > Adam > > On 7/20/07, Shandy Nantz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > > > > I have been working on this small, minute, part on my project and it all > > hinges on setting the value in a text_field helper. Saying: > > > <%= text_field ''user'', ''company'', :value => @login %> > > > does not do it. When I go and look at the raw html, there is no value > > there and "value" is an attribute of the input tag, im pretty sure. I > > really like RoR and how things work, but they fail miserably when it > > comes to documentation. Anybody know of any good reference sites besides > >http://api.rubyonrails.org/?Thanks, > > > ~S > > > -- > > Posted viahttp://www.ruby-forum.com/.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---