coolJay
2007-Dec-28 01:12 UTC
What''s the best way to pass string value from View to Controller?
I need to pass a string value from view to controller besides the form_remote_tag value... What''s the best way to do it? Is it possible to pass a parameter in send_data method? For instance, send_data( channel_info) ? Currently, I have the code as follows... but I need to pass in the string value to controller with chat_input value. I can really figure out a clean way to do it. Please let me know. Thanks~! View code.... ------------------------------------ <%= form_remote_tag( :url => { :action => :send_data }, :complete => "$(''chat_input'').value = ''''" ) %> <%= text_field_tag( ''chat_input'', '''', { :size => 20, :id => ''chat_input''} ) %> <%= submit_tag "Add" %> </form> Controller code... ------------------------------------- def send_data ...... end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg
2007-Dec-28 01:17 UTC
Re: What''s the best way to pass string value from View to Controller?
You''re already doing it. you just just add more fields to the form depending on what information exactly you want to send to the page. On Dec 28, 2007 11:42 AM, coolJay <hoonjailee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I need to pass a string value from view to controller besides the > form_remote_tag value... > > What''s the best way to do it? > > Is it possible to pass a parameter in send_data method? > > For instance, send_data( channel_info) ? > > > Currently, I have the code as follows... but I need to pass in the > string value to controller with chat_input value. > > I can really figure out a clean way to do it. > > Please let me know. Thanks~! > > View code.... > ------------------------------------ > <%= form_remote_tag( :url => { :action => :send_data }, :complete => > "$(''chat_input'').value = ''''" ) %> > <%= text_field_tag( ''chat_input'', '''', { :size => 20, :id => > ''chat_input''} ) %> > <%= submit_tag "Add" %> > </form> > > Controller code... > ------------------------------------- > def send_data > ...... > end > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
coolJay
2007-Dec-28 01:25 UTC
Re: What''s the best way to pass string value from View to Controller?
Ryan, Thanks for you reply. Actually, that''s what I am doing right now. But I want to make the information that is passed from view to controller invisible to user. I acutally do have one more form_remote_tag field, which is <%= text_field_tag :channel_info ,@channel, {:size=>20} %> But doing it this way, it''s visible and modifiable to and by user. (I made diabled option turn on, then it wouldn''t let me pass the value in it) Any other idea or suggestion? Thanks~! On 12월28일, 오전10시17분, "Ryan Bigg" <radarliste...@gmail.com> wrote:> You''re already doing it. you just just add more fields to the form depending > on what information exactly you want to send to the page. > > On Dec 28, 2007 11:42 AM, coolJay <hoonjai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I need to pass a string value from view to controller besides the > > form_remote_tag value... > > > What''s the best way to do it? > > > Is it possible to pass a parameter in send_data method? > > > For instance, send_data( channel_info) ? > > > Currently, I have the code as follows... but I need to pass in the > > string value to controller with chat_input value. > > > I can really figure out a clean way to do it. > > > Please let me know. Thanks~! > > > View code.... > > ------------------------------------ > > <%= form_remote_tag( :url => { :action => :send_data }, :complete => > > "$(''chat_input'').value = ''''" ) %> > > <%= text_field_tag( ''chat_input'', '''', { :size => 20, :id => > > ''chat_input''} ) %> > > <%= submit_tag "Add" %> > > </form> > > > Controller code... > > ------------------------------------- > > def send_data > > ...... > > end > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.- 따온 텍스트 숨기기 - > > - 따온 텍스트 보기 ---~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robert Head
2007-Dec-28 01:40 UTC
Re: What''s the best way to pass string value from View to Co
coolJay wrote:> > <%= text_field_tag :channel_info ,@channel, {:size=>20} %>See hidden_field_tag. http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M001039 -- 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 -~----------~----~----~----~------~----~------~--~---
coolJay
2007-Dec-28 01:53 UTC
Re: What''s the best way to pass string value from View to Co
Robert, Thank you for your help. I am obviously a newbie to rails and web programing community as well... Again Thanks~! Jay On 12월28일, 오전10시40분, Robert Head <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> coolJay wrote: > > > <%= text_field_tag :channel_info ,@channel, {:size=>20} %> > > See hidden_field_tag.http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.h... > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Donald
2007-Dec-28 22:47 UTC
Re: What''s the best way to pass string value from View to Controller?
On 12/27/07, coolJay <hoonjailee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Actually, that''s what I am doing right now. But I want to make the > information that is passed from view to controller invisible to user. > > I acutally do have one more form_remote_tag field, which is > > <%= text_field_tag :channel_info ,@channel, {:size=>20} %> > > But doing it this way, it''s visible and modifiable to and by user. (I > made diabled option turn on, then it wouldn''t let me pass the value in > it) > > Any other idea or suggestion?Way back in HTML 2.0 they invented the hidden field tag: http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.1.2.6 In Rails it''s called hidden_field or hidden_field_tag depending on your form setup: http://api.rubyonrails.com/classes/ActionView/Helpers/FormHelper.html#M000925 http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M001039 -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---