hi everyone I have two url_to action, like this converter: ''<%= url_for :controller => ''/project/report'', :action => ''converter'' %>'', work_sheet_csv: ''<%= url_for :controller => ''/project/report'', :action => ''work_sheet_csv'' %>'', and I have a selection like <select name="templates"> <option value="work_sheet_csv">csv</option> <option value="template_of_roster">template_of_roster</option> <option value="template_of_roster1">template_of_roster1</option> <option value="template_of_roster2">template_of_roster2</option> <option value="template_of_roster3">template_of_roster3</option> </select> I have a button and I want to write condition for two url. when I select csv and click button, want to run work_sheet_csv, when I select one of the templates, want to run converter. how can I write condition for it. thanks for any help... -- 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 -~----------~----~----~----~------~----~------~--~---
Use select tag like this select_tag(''id'', options_for_select([[foo],[bar]]), :onchange=>remote_function(:url =>{:action => ''yr_rails_method''},:with => "''id=''+this.value", :method=>:post),:style => "width: 220px;font-size: 90%;" ) in yr rails method u can check for the value("''id=''+this.value") and redirect it. All the best -- 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 -~----------~----~----~----~------~----~------~--~---
Simplify your public interface and just use one action. Since converter handles most of the possibilities, I''d default to it and allow it to delegate to work_sheet_csv if necessary. def convert work_sheet_csv and return if params[:tempates]==''work_sheet_csv'' ... current convert code ... end private def work_sheet_csv ... end If that feels uncomfortable, then use a new action and let it simply delegate all the calls to either converter or work_sheet_csv as necessary. On Feb 20, 1:57 am, Ibrahim Dogru <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> hi everyone > > I have two url_to action, like this > > converter: ''<%= url_for :controller => ''/project/report'', :action > => ''converter'' %>'', > > work_sheet_csv: ''<%= url_for :controller => ''/project/report'', :action > => ''work_sheet_csv'' %>'', > > and I have a selection like > > <select name="templates"> > <option value="work_sheet_csv">csv</option> > <option value="template_of_roster">template_of_roster</option> > <option value="template_of_roster1">template_of_roster1</option> > <option value="template_of_roster2">template_of_roster2</option> > <option value="template_of_roster3">template_of_roster3</option> > </select> > > I have a button and I want to write condition for two url. when I select > csv and click button, want to run work_sheet_csv, when I select one of > the templates, want to run converter. > > how can I write condition for it. > thanks for any help... > -- > 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 -~----------~----~----~----~------~----~------~--~---
Ratnavel Sundaramurthi wrote:> Use select tag like this > > > select_tag(''id'', options_for_select([[foo],[bar]]), > :onchange=>remote_function(:url =>{:action => ''yr_rails_method''},:with > => "''id=''+this.value", :method=>:post),:style => "width: > 220px;font-size: 90%;" ) > > in yr rails method u can check for the value("''id=''+this.value") and > redirect it. > > All the bestthank you very much for your help. I have a question to your suggestion. first I need to use the value of option because another method need it as well. another thing is that it s not object of form. selection is not used in form. lastly there will be button which should realize the selection and run the suitable url. as you see in selection there are some template names and work_sheet_csv. I will use another selection if I manage to get parameter from selection. btw thank you very much for your help Ratnavel Sundaramurthi... -- 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 -~----------~----~----~----~------~----~------~--~---
Ibrahim Dogru : I advice you to paste your both of your controllers and index.rhtml using http://pastie.caboo.se/ and paste the links here, so they can understand the main your problem. I believe they can solve the problem if they can read your entire script, because your problem is how to call first the url of csv from your javascript function that you wrote in index.rhtml. I am not good in JS. Reinhart Ariando -- 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 -~----------~----~----~----~------~----~------~--~---
Visit Indonesia 2008 wrote:> Ibrahim Dogru : > > I advice you to paste your both of your controllers and index.rhtml > using http://pastie.caboo.se/ and paste the links here, so they can > understand the main your problem. I believe they can solve the problem > if they can read your entire script, because your problem is how to call > first the url of csv from your javascript function that you wrote in > index.rhtml. I am not good in JS. > > Reinhart Ariandomy problem is that get parameter from selection which is not in form object. thank you very much for your help Reinhart Ariando. you spent your time for me. -- 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 -~----------~----~----~----~------~----~------~--~---