Hi all, I am implementing the functionality of cascading drop downs of countries and states. I want this to be done with Ajax and ruby so that the page dont get refreshed on selecting the country in first drop down. Currently I have implemented it with java script and ruby. But the problem is the page get refreshed when i select the country from countries drop down. Can some one help me out in implementing this functionality. Any help would be greatly appreciated. -Regards Ruchita Sharma. -- 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 -~----------~----~----~----~------~----~------~--~---
Ruchita Sharma wrote:> Hi all, > > I am implementing the functionality of cascading drop downs of countries > and states. I want this to be done with Ajax and ruby so that the page > dont get refreshed on selecting the country in first drop down. > > Currently I have implemented it with java script and ruby. But the > problem is the page get refreshed when i select the country from > countries drop down. Can some one help me out in implementing this > functionality. > > > > Any help would be greatly appreciated. > > > > -Regards > Ruchita Sharma.Hi Ruchita, In Ajax the main advantage is that we can refresh the page in parts ie, buy defining divisions in view file as <div id = "some name"> </div> and updating only this div as :update => "some name" But at this juncture what I feel is that it is not due to abscence of Ajax but it is due to your code logic that the page is refreshing while selecting country only. Any way may be I can help you if you can send me some code especially that part where you implement drop down list 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Ruchita Sharma wrote: >> Hi all, >> >> I am implementing the functionality of cascading drop downs of countries >> and states. I want this to be done with Ajax and ruby so that the page >> dont get refreshed on selecting the country in first drop down. >> >> Currently I have implemented it with java script and ruby. But the >> problem is the page get refreshed when i select the country from >> countries drop down. Can some one help me out in implementing this >> functionality. >> >> >> >> Any help would be greatly appreciated. >> >> >> >> -Regards >> Ruchita Sharma. > Hi Ruchita, > > In Ajax the main advantage is that we can refresh the page in parts ie, > buy defining divisions in view file as > <div id = "some name"> > </div> > and updating only this div as :update => "some name" > > But at this juncture what I feel is that it is not due to abscence of > Ajax but it is due to your code logic that the page is refreshing while > selecting country only. Any way may be I can help you if you can send me > some code especially that part where you implement drop down list > > All the BestHi Abhi Manyu, The part of the code where i am implementing it as follows. Can you plz tell me where is the problem. <tr align="center"> <td>First Name</td> <td> <input id="user_first_name" name="user[first_name]" size="30" type="text" value=""/></td> </tr> <tr align="center"> <td>Last Name</td> <td> <input id="user_last_name" name="user[last_name]" size="30" type="text" value=""/></td> </tr> <tr align="center"> <td>Country</b><br/></td> <td> <!--select name="country[country_id]"--> <select id="category2" onchange="goToSub();" > <% @countries.each do |country| %> <option value="<%= country.id %>" <%= '' selected'' if country.id == @user.country_id %>> <%= country.country_name %> </option> <% end %> </select> <input type ="hidden" id="categorytxt" name="textbox1" size="30" /> </td> </tr> <script language="javascript"> function goToSub() { window.location="../user/new_client?categoryid=" + category2.options[category2.selectedIndex].value; } </script> <input type="submit" name="go" value="go" onClick="goToSub();"> <% @rubyVar=request.parameters["categoryid"] %> <input type ="text" id="categorytxt" name="textbox1" size="30" value= <%= @rubyVar %> > <tr align="center"> <td>State</td> <td> <select name="user[state_id]"> <% @states.each do |state| %> <% if (state.country_id == (@rubyVar.to_i)) %> <option value="<%= state.country_id %>" <%= '' selected'' %>> <%= state.state_name %> </option> <% end %> <% end %> </select> </td> </tr> <tr align="center"> <td>City</b><br/> <td> <input id="user_city" name="user[city]" size="30" type="text" value=""/></td> </tr> <tr align="center"> <td>Zip Code</b><br/> <td> <input id="user_zip" name="user[zip]" size="30" type="text" value=""/></td> </tr> Thanks, Ruchita Sharma -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Ruchita In your code you are telling like <select id="category2" onchange="goToSub();" > ie whenever there is a change in country dropdown selection list control should go to function goToSub() which inturn will load the other part rt?. So that is why it is getting refreshed I will check some solution and get back to you Thanks Abhimanyu -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> > Hi Ruchita > > In your code you are telling like > <select id="category2" onchange="goToSub();" > > ie whenever there is a change in country dropdown selection list control > should go to function goToSub() which inturn will load the other part > rt?. So that is why it is getting refreshed > > I will check some solution and get back to you > > Thanks > AbhimanyuYeah.... In function goToSub(); I am fetching the value of country id. window.location="../user/new_client?categoryid=" + category2.options[category2.selectedIndex].value; Then i am getting this id by using this line of code: <% @rubyVar=request.parameters["categoryid"] %> In the states drop down i am comparing: if (state.country_id == (@rubyVar.to_i)) then corresponding to this, states are displayed. The problem is whenever I select the country, the fields which are above the country are lost perhaps due to refreshing of page. Thanks, Ruchita Sharma -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> > Hi Ruchita > > In your code you are telling like > <select id="category2" onchange="goToSub();" > > ie whenever there is a change in country dropdown selection list control > should go to function goToSub() which inturn will load the other part > rt?. So that is why it is getting refreshed > > I will check some solution and get back to you > > Thanks > AbhimanyuHi Ruchita Sorry I have to reach some place. so I will post you tommorrow only. Also try to use Collection_select instead of "option" to show drop down list so that you can include many options. check some tutorials on collection_select if you dont know that or else I will tell you tomorrow Thanks Abhimanyu -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Abhi Manyu wrote: >> >> Hi Ruchita >> >> In your code you are telling like >> <select id="category2" onchange="goToSub();" > >> ie whenever there is a change in country dropdown selection list control >> should go to function goToSub() which inturn will load the other part >> rt?. So that is why it is getting refreshed >> >> I will check some solution and get back to you >> >> Thanks >> Abhimanyu > > Hi Ruchita > > Sorry I have to reach some place. so I will post you tommorrow only. > Also try to use Collection_select instead of "option" to show drop down > list so that you can include many options. check some tutorials on > collection_select if you dont know that or else I will tell you tomorrow > > Thanks > > AbhimanyuHi Thanks a lot. Not an issue but please do help me out. -Ruchita -- 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 -~----------~----~----~----~------~----~------~--~---
Hi
<td><%=
collection_select("country","name",@countries,"id","name",{:onchange
=>
"javascript:selectedData(this.options[selectedIndex].value)"})
%></td>
--
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
-~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi > <td><%= > collection_select("country","name",@countries,"id","name",{:onchange => > "javascript:selectedData(this.options[selectedIndex].value)"}) %></td>function selectedData(selectedvalue) { var codeid = selectedvalue; <%= remote_function(:update => ''show'', :url => showdescription_url,:with => "''value=''+encodeURIComponent(codeid)")%> } -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Abhi Manyu wrote: >> Hi >> <td><%= >> collection_select("country","name",@countries,"id","name",{:onchange => >> "javascript:selectedData(this.options[selectedIndex].value)"}) %></td> >function selectedData(selectedvalue) { var stateid = selectedvalue; <%= remote_function(:update => ''show'', :url => showstate_url,:with => "''value=''+encodeURIComponent(stateid)")%> } you have to use roots.rb then shoud have a div called show in the view file where you specify the drop down list of countries <div id= ''show''> <%=render:partial => states> <\div> -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Abhi Manyu wrote: >> Abhi Manyu wrote: >>> Hi >>> <td><%= >>> collection_select("country","name",@countries,"id","name",{:onchange => >>> "javascript:selectedData(this.options[selectedIndex].value)"}) %></td> >> > > function selectedData(selectedvalue) > { > var stateid = selectedvalue; > <%= remote_function(:update => ''show'', :url => > showstate_url,:with => "''value=''+encodeURIComponent(stateid)")%> > } > > you have to use roots.rb > then shoud have a div called show in the view file where you specify the > drop down list of countries > > <div id= ''show''> > <%=render:partial => states> > <\div>Hi, Can you gmmme full code. Am not able to implement it in my code. -- 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 -~----------~----~----~----~------~----~------~--~---
Hi,
I have given only some idea to you. Its not part of any code . You can
use collection select for drop down list
and if any country is selected then javascript function function
selectedData(selectedvalue) is called. In that function itself it will
call other action
function selectedData(selectedvalue)
{
var stateid = selectedvalue;
<%= remote_function(:update => ''show'', :action
=>
action_name,:with =>
"''value=''+encodeURIComponent(stateid)")%>
}
write the state drop down list in a partial file and render that file in
the above action you call
and also define a div called show in the view file of country drop down
and render the partial file here also.
Please try this
--
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
-~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi, > I have given only some idea to you. Its not part of any code . You can > use collection select for drop down list > and if any country is selected then javascript function function > selectedData(selectedvalue) is called. In that function itself it will > call other action > > > function selectedData(selectedvalue) > { > var stateid = selectedvalue; > <%= remote_function(:update => ''show'', :action => > action_name,:with => "''value=''+encodeURIComponent(stateid)")%> > } > > > write the state drop down list in a partial file and render that file in > the above action you call > > and also define a div called show in the view file of country drop down > and render the partial file here also. > > Please try thisOkie.... let me try to implement this. Thanks for your help. I''ll get back to you. -- 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 -~----------~----~----~----~------~----~------~--~---
Ruchita Sharma wrote:> Abhi Manyu wrote: >> Hi, >> I have given only some idea to you. Its not part of any code . You can >> use collection select for drop down list >> and if any country is selected then javascript function function >> selectedData(selectedvalue) is called. In that function itself it will >> call other action >> >> >> function selectedData(selectedvalue) >> { >> var stateid = selectedvalue; >> <%= remote_function(:update => ''show'', :action => >> action_name,:with => "''value=''+encodeURIComponent(stateid)")%> >> } >> >> >> write the state drop down list in a partial file and render that file in >> the above action you call >> >> and also define a div called show in the view file of country drop down >> and render the partial file here also. >> >> Please try this > > > Okie.... let me try to implement this. Thanks for your help. I''ll get > back to you.Thanks a lot for your help. I have implemented the drop downs. Now the problem is I have to save the data of the country and state in the users table. I dont know how to save the country and state in the database because i am fetching the data from the countries and states table but i have to make it save in users table. Please do let me know. Ruchita Thanks -- 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 -~----------~----~----~----~------~----~------~--~---
Hi For that you have to have associations between the users table and countries as well as states table Use the country id and state id as foreign keys in users table By the way did you use collection_select to implement dropdrown .Did you solve the previous problem Please let me know All the Best Abhimanyu -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> > Hi > > For that you have to have associations between the users table and > countries as well as states table > > Use the country id and state id as foreign keys in users table > > By the way did you use collection_select to implement dropdrown .Did you > solve the previous problem > Please let me know > > All the Best > > AbhimanyuHi Abhimanyu See I have a users table, countries table and a states table. I am taking foreign key country_id and state_id in users table. I hav used collection_select to implement the drop downs. Shall I send you the code to make it more clear? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Ruchita Yes Please send me the code. You can use the foreign keys as you sent.Some times I wont be able to reply today . May be between morning and evening we can have discussion. Are you a student . I asked because If you are free other times we can have discussion then. I will be leaving after a short while THANKS ABHIMANYU -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi Ruchita > > Yes Please send me the code. You can use the foreign keys as you > sent.Some times I wont be able to reply today . May be between morning > and evening we can have discussion. > > Are you a student . I asked because If you are free other times we can > have discussion then. I will be leaving after a short while > THANKS > ABHIMANYUHi <td> <% collection_select(:country, :country_name, @countries, :id, :country_name, options = {:prompt => " Select a Country "}, html_options { :onChange => "new Ajax.Updater(''dd_cities'', ''/user/country_changed/'' + this[this.selectedIndex].value, {asynchronous:true, evalScripts:true});" } ) %> </td></tr> <tr align="center"><td>State</td> <td> <span id="dd_cities"> <%render :partial => "states", :locals => { :country_id => @countries[0].id} %> </span> This is what i have written code in controller. I have made a _states.rhtml. Now i am able to save the data in my users table. I am not a student. Tomorrow wud be my off, so plz if p''ble do let me knw wat needs to be done? Thanks, Ruchita Sharma. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ruchita Sharma wrote: Hi, I mean i am not able to save data in users table. -- 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 -~----------~----~----~----~------~----~------~--~---
Ruchita Sharma wrote:> Ruchita Sharma wrote: > > Hi, > > I mean i am not able to save data in users table.Hi, I am getting the following error when i click on save button: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.inject Extracted source (around line #31): 28: <td>Country</b><br/></td> 29: <td> 30: <%31: collection_select(:country, :country_name, @countries, :id, :country_name, 32: options = {:prompt => "� Select a Country �"}, 33: html_options 34: { Do let me know what needs to be done? Thanks Ruchita Sharma. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ruchita Sharma wrote:> Hi all, > > I am implementing the functionality of cascading drop downs of countries > and states. I want this to be done with Ajax and ruby so that the page > dont get refreshed on selecting the country in first drop down. > > Currently I have implemented it with java script and ruby. But the > problem is the page get refreshed when i select the country from > countries drop down. Can some one help me out in implementing this > functionality. > > > > Any help would be greatly appreciated. > > > > -Regards > Ruchita Sharma.Hi please tell me the fields of the country,state and users table collection_select(:country, :country_name, @countries, :id, :country_name, here the :country_name after :id is it a field in countries table? -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Ruchita Sharma wrote: >> Hi all, >> >> I am implementing the functionality of cascading drop downs of countries >> and states. I want this to be done with Ajax and ruby so that the page >> dont get refreshed on selecting the country in first drop down. >> >> Currently I have implemented it with java script and ruby. But the >> problem is the page get refreshed when i select the country from >> countries drop down. Can some one help me out in implementing this >> functionality. >> >> >> >> Any help would be greatly appreciated. >> >> >> >> -Regards >> Ruchita Sharma. > > Hi > please tell me the fields of the country,state and users table > collection_select(:country, :country_name, @countries, :id, > :country_name, > > here the :country_name after :id is it a field in countries table?Hi Abhimanyu, The fields of countries table are id and country_name. The fields of states table are id, country_id and state_name. The fields of users table are id, login, first_name,and so on including country_id and state_id. Now please do let me know what needs to be done? Yes country_name is a field in countries table. -- 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 -~----------~----~----~----~------~----~------~--~---
bala kishore pulicherla
2007-Oct-29 04:39 UTC
Re: Implementing countries and states drop down
you can use observe filed On 10/29/07, Ruchita Sharma <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Abhi Manyu wrote: > > Ruchita Sharma wrote: > >> Hi all, > >> > >> I am implementing the functionality of cascading drop downs of > countries > >> and states. I want this to be done with Ajax and ruby so that the page > >> dont get refreshed on selecting the country in first drop down. > >> > >> Currently I have implemented it with java script and ruby. But the > >> problem is the page get refreshed when i select the country from > >> countries drop down. Can some one help me out in implementing this > >> functionality. > >> > >> > >> > >> Any help would be greatly appreciated. > >> > >> > >> > >> -Regards > >> Ruchita Sharma. > > > > Hi > > please tell me the fields of the country,state and users table > > collection_select(:country, :country_name, @countries, :id, > > :country_name, > > > > here the :country_name after :id is it a field in countries table? > > Hi Abhimanyu, > > The fields of countries table are id and country_name. The fields of > states table are id, country_id and state_name. The fields of users > table are id, login, first_name,and so on including country_id and > state_id. > > Now please do let me know what needs to be done? > > Yes country_name is a field in countries table. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Hi Ruchita
Try to use submit_to_remote like this
<td><%= collection_select(:country,":country_name,@countries,
:id,:country_name,{:onchange => "new
Ajax.Updater(''dd_cities'',
''/user/country_changed/'' +
this[this.selectedIndex].value,
{asynchronous:true, evalScripts:true});") %></td>
<td><%= submit_to_remote("save", "Save", :url =>
{:action =>"action
name", :update => "dd_cities") %></td>
--
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
-~----------~----~----~----~------~----~------~--~---
Hi the code you sent . is this in a partial file? -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi Ruchita > > Try to use submit_to_remote like this > > <td><%= collection_select(:country,":country_name,@countries, > :id,:country_name,{:onchange => "new Ajax.Updater(''dd_cities'', > ''/user/country_changed/'' + this[this.selectedIndex].value, > {asynchronous:true, evalScripts:true});") %></td> > > <td><%= submit_to_remote("save", "Save", :url => {:action =>"action > name", :update => "dd_cities") %></td>Hi, Its not working. Is there some other method to implement it? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi is it syntax error -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi > is it syntax erroryes, td><%= collection_select(:country,":country_name,@countries,> :id,:country_name,{:onchange => "new Ajax.Updater(''dd_cities'', > ''/user/country_changed/'' + this[this.selectedIndex].value, > {asynchronous:true, evalScripts:true});") %></td>You havnt closed the double quotes starting before country_name. I hav tried all the options but it''s not working. Moreover, I am not getting where to use the second line of code u have send? My code is as follows: <td> <% collection_select(:country, :country_name, @countries, :id, :country_name, options = {:prompt => " Select a Country "}, html_options { :onChange => "new Ajax.Updater(''dd_cities'', ''/user/country_changed/'' + this[this.selectedIndex].value, {asynchronous:true, evalScripts:true});" } ) %> </td></tr> <tr align="center"><td>State</td> <td> <span id="dd_cities"> <%render :partial => "states", :locals => { :country_id => @countries[0].id} %> Now tell me how to implement dt stuff. Thanks, Ruchita -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi
<td><%= collection_select(:country,":country_name,@countries,
:id,:country_name,{:onchange =>
"javascript:selectedData(this.options[selectedIndex].value)"}")
%></td>
<td><%= submit_to_remote("save", "Save", :url =>
{:action =>"action
name"}, :update => "dd_cities") %></td>
There should be a function "selectedData(selectedIndex)" and inside
the
function you should have following line
var country_id = selectedIndex
<%= remote_function(:update => ''dd_cities'', :url =>
{:action =>"action
name"},:with =>
"''value=''+encodeURIComponent(country_id )")%>
and
<div id = "dd_cities">
</div>
I forgot to put "}" earlier
--
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
-~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote: Hi sorry there is no double quotes there the second line of code is to save the data that you can write after collection_select itself . But if you want to save states also <div id = "dd_cities"> </div> be within form tag -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Abhi Manyu wrote: > Hi > sorry there is no double quotes there > the second line of code is to save the data that you can write after > collection_select itself . But if you want to save states also > <div id = "dd_cities"> > > </div> > be within form tagHi, It''s not working and I have to get it done today only. -- 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 -~----------~----~----~----~------~----~------~--~---
My advice is to use observer field, instead using javascript codes. its really messy On Oct 29, 10:03 am, Abhi Manyu <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi > the code you sent . is this in a partial file? > -- > 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 -~----------~----~----~----~------~----~------~--~---
Check this link for observer field, same like that you can do it for select. http://www.recentrambles.com/pragmatic/view/59 --~--~---------~--~----~------------~-------~--~----~ 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 If you are still using javascript send me the updated code or else if you are in hurry then try as Mr Bala has suggested for some time(say 1 hr max) Because its not good to change the flow often . Also javascript is not that much messy if get used to it. I hope I have not confused you in our discussions all along -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi > > If you are still using javascript send me the updated code or else if > you are in hurry then try as Mr Bala has suggested for some time(say 1 > hr max) Because its not good to change the flow often . Also javascript > is not that much messy if get used to it. I hope I have not confused you > in our discussions all along.Hi, I am really very confused. I am using javascript code only.... dont want to change the flow. I am sending you the code of view as well as that of controller. I know what the problem is but really dont hav an idea wat to do? The name of view is new_client.rhtml. <%= javascript_include_tag :defaults %> <div id="flashes"><%= show_flashes :notice, :warning %></div> <h2 align="center">Add New Client</h2> <form action="/user/create_client" method="post"> <table align="center" border="1"> <tr align="center"> <td>Login</td> <td> <input id="user_login" name="user[login]" size="30" type="text" value=""/></td> </tr> <tr align="center"> <td>Password</td> <td> <input id="user_password" name="user[password]" size="30" type="text" value=""/></td> </tr> <tr align="center"> <td>Confirm Password</td> <td> <input id="user_password" name="user[password]" size="30" type="text" value=""/></td> </tr> <tr align="center"> <td>First Name</td> <td> <input id="user_first_name" name="user[first_name]" size="30" type="text" value=""/></td> </tr> <tr align="center"> <td>Last Name</td> <td> <input id="user_last_name" name="user[last_name]" size="30" type="text" value=""/></td> </tr> <tr align="center"> <td>Country</b><br/></td> <td> <% collection_select(:country, :country_name, @countries, :id, :country_name, options = {:prompt => " Select a Country "}, html_options { :onChange => "new Ajax.Updater(''dd_cities'', ''/user/country_changed/'' + this[this.selectedIndex].value, {asynchronous:true, evalScripts:true});" } ) %> </td></tr> <tr align="center"><td>State</td> <td> <span id="dd_cities"> <%render :partial => "states", :locals => { :country_id => @countries[0].id} %> </span> </td></tr> <tr align="center"> <td>Phone</b><br /></td> <td> <input id="user_phone" name="user[phone]" size="30" type="text" value=""/></td> </tr> </table> <input type="submit" align="center" value="Create"/> </form> user controller: def new_client @user = User.new @countries = Country.find :all @states = State.find :all @countries = Country.find(:all, :order => ''country_name'') @states = State.find_by_state_name(params[:id]) end def create_client @user = User.new(params[:user]) @user.country_id=params[:country][:country_name] @user.state_id=params[:state][:state_name] if @user.save redirect_to :action => ''list_user'' else render :action => ''new_client'' end end Drop downs are working fine but am not able to save data in users table. Thanks a lot, Ruchita -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi if drop down is working fine Please use breakpoint in the controller to check that whether the values params[:country][:country_name] and params[:state][:state_name] and let me know -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi > if drop down is working fine > Please use breakpoint in the controller to check that whether the values > params[:country][:country_name] and > params[:state][:state_name] and let me knowHi, Both values are coming right. But the control is not going after if @user.save.... and therefore no data is being saved in the database. Let me know if if i have done some mistake. -- 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 -~----------~----~----~----~------~----~------~--~---
Try removing @user = User.new from action new_client and replace @user = User.new(params[:user]) by @user = User.new -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Try removing > @user = User.new from action new_client and replace > @user = User.new(params[:user]) by @user = User.newStill not working. Again the control is not going after if @user.save. What should be done? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi tell me how you know its not getting saved did you checked db. refresh it and check . Here maybe "if" statement is not working -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi tell me how you know its not getting saved did you checked db. > refresh it and check . Here maybe > "if" statement is not workingYes i have checked the database. Data is not getting saved. -- 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 -~----------~----~----~----~------~----~------~--~---
class User < ActiveRecord::Base is this written in your model? -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> class User < ActiveRecord::Base > > is this written in your model?Model is: class User < ActiveRecord::Base belongs_to :role belongs_to :designation belongs_to :country belongs_to :state end -- 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 -~----------~----~----~----~------~----~------~--~---
Ruchita Sharma wrote:> Abhi Manyu wrote: >> class User < ActiveRecord::Base >> >> is this written in your model? > > Model is: > class User < ActiveRecord::Base > belongs_to :role > belongs_to :designation > belongs_to :country > belongs_to :state > endAny other association that needs to be made? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi please give a breakpoint @user before @user.save and please close the db if its open -- 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 -~----------~----~----~----~------~----~------~--~---
let me know if values are there -- 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 -~----------~----~----~----~------~----~------~--~---
> Abhi Manyu wrote: > >> Try removing >> @user = User.new from action new_client and replace >> @user = User.new(params[:user]) by @user = User.new >> > > Still not working. Again the control is not going after if @user.save. > What should be done? >Try @user.save! instead of @user.save and check log/development.log what error is thrown... Alternative method: run script/console and simulate the user creation via command line (remember to save user with this method user.save! !!!) Good luck ! Tex. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> let me know if values are thereHi Abhi Manyu, Its not responding. I had given a breakpoint before @user.save and its not responding. -- 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 -~----------~----~----~----~------~----~------~--~---
Gianluca Tessarolo wrote:>> Abhi Manyu wrote: >> >>> Try removing >>> @user = User.new from action new_client and replace >>> @user = User.new(params[:user]) by @user = User.new >>> >> >> Still not working. Again the control is not going after if @user.save. >> What should be done? >> > Try @user.save! instead of @user.save and check log/development.log what > error is thrown... > > Alternative method: run script/console and simulate the user creation > via command line (remember to save user with this method user.save! !!!) > > Good luck ! > > Tex.Hi Abhi Manyu, Its working now. I have commented all the validations in user''s model and now its working. Thanks a lot for your help. Thank you so much. -Ruchita Sharma. -- 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 -~----------~----~----~----~------~----~------~--~---
So validation was the problem ? I am very happy for you Ruchita.Past 4-5 days I had a good experience in ror because of you, So thank you. And today I think I felt atleast 10 % of your pressure and tension. Felt Good to work with you Hope that you will keep in touch my mail id is 55.abhimanyu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Thannks and 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> So validation was the problem ? > > > I am very happy for you Ruchita.Past 4-5 days I had a good experience in > ror because of you, So thank you. And today I think I felt atleast 10 % > of your pressure and tension. Felt Good to work with you > > Hope that you will keep in touch my mail id is 55.abhimanyu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > Thannks and All the BestHi Abhimanyu, Thanks a lot for your help and support. Yeah sure i will definitely be in touch with you. Thanks again and All the Best to you too. -- 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 -~----------~----~----~----~------~----~------~--~---
KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-29 13:10 UTC
Re: Implementing countries and states drop down
I''ve been following this thread for days and was hoping someone might share a simple ''boiler-plate'' example for us ''bottom-feeders'' to utilize. This example of country - zipcode has many applications and I''d love to integrate it into my code. If anyone has an example of this working, I''d be very grateful to view it. Thanks, Kathleen KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org On Oct 28, 11:03 pm, Abhi Manyu <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi > the code you sent . is this in a partial file? > -- > 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 Abhimanyu, I am implementing the functionality where I have three tables one is users table, second is groups table, and the third is users_groups table. This is the join table of users and groups where i have user_id and group_id. In users group i have a field type_id which identifies the type of user. Now by using these three tables I have to show the users whose type is resources and they belong to a particular group. Please suggest me the way of implementing this functionality. Thanks, Ruchita -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Ruchita
Let me tell you what I understood
You have users table having fields id,...
groups table having field id,...
and usergroup table having fileds user_id, groups_id,usertype_id
Is that correct?
--
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
-~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi Ruchita > > Let me tell you what I understood > > You have users table having fields id,... > groups table having field id,... > and usergroup table having fileds user_id, groups_id,usertype_id > > Is that correct?Hi Abhimanyu, I need to implement a drop down for types of users. If type of user is resource only then the second drop down needs to be filled with the types of groups. I have implemented it with javascript but again the same problem, and am not able to implement it with Ajax. The fields of users table have type_id but the resource table don''t have any type_id field so i am doing it by passing the id as 3 coz in types table the users whose type is resouces hav id 3. Please tell me how to implement it with Ajax. Shall i use observe field. -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Ruchita,
Ok If you have time try with observe field. I havent tried in it
that much yet. Its good if you try other options if you have time, as
you can study those
--
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
-~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi Ruchita, > Ok If you have time try with observe field. I havent tried in it > that much yet. Its good if you try other options if you have time, as > you can study thoseOkie.... let me try. I''ll let you know. Are you working in RoR? -- 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 -~----------~----~----~----~------~----~------~--~---
yes and you? -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> yes and you?Yes me too :) -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Other thing is over? .Is this ur new project. r u working in India? -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi > > Other thing is over? .Is this ur new project. r u working in India?No that thing is still pending. Wud do it tomorrow. Yeah ds is my new project and i am working in India. Wat abt u? -- 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 -~----------~----~----~----~------~----~------~--~---
yes me too -- 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 -~----------~----~----~----~------~----~------~--~---
whats your mail id? -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> whats your mail id?its ruchita6-Re5JQEeQqe9fmgfxC/sS/w@public.gmane.org -- 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 -~----------~----~----~----~------~----~------~--~---
Hi By the way I am a newbie in this field -- 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 -~----------~----~----~----~------~----~------~--~---
Abhi Manyu wrote:> Hi By the way I am a newbie in this fieldEven i am new in this technology. Dont hav dt much experience dt''s why i always post queries on forums. -- 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 -~----------~----~----~----~------~----~------~--~---
Ruchita Sharma wrote:> Abhi Manyu wrote: >> Hi By the way I am a newbie in this field > > Even i am new in this technology. Dont hav dt much experience dt''s why i > always post queries on forums.Hi Abhimanyu, Please tell me how to work with join table? I have users table having fields id,type_id.... groups table having field id,type_id..... types table having fileds id,type_name..... and usergroups table having fields user_id, groups_id. Now I have to display users who belongs to a particular group. -- 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 -~----------~----~----~----~------~----~------~--~---
KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-31 12:40 UTC
Re: Implementing countries and states drop down
I sent this message two days ago but it was never posted? Could someone include an example of two dropdown list boxes in a more simplified format so that others could study it? This example by Abhi is too specific for me to see the ''forest through the trees''. I think we all must do something similar at times such as category - subcategory or month - day or country - state at times. I would be grateful if anyone has performed this TWO contingent select boxes, or perhaps someone would find this as substance for a good blog? Thank you, Kathleen On Oct 28, 11:03 pm, Abhi Manyu <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi > the code you sent . is this in a partial file? > -- > 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 -~----------~----~----~----~------~----~------~--~---
KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I sent this message two days ago but it was never posted? > Could someone include an example of two dropdown list boxes in a more > simplified format so that others could study it? This example by Abhi > is too specific for me to see the ''forest through the trees''. I think > we all must do something similar at times such as category - > subcategory or month - day or country - state at times. > I would be grateful if anyone has performed this TWO contingent select > boxes, or perhaps someone would find this as substance for a good > blog? > Thank you, > Kathleen > > > On Oct 28, 11:03 pm, Abhi Manyu <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Hi Kathleen, I have implemented a countries drop down and corresponding to that the states are automatically gets filled in second drop down. I have implemented it through Ajax. If you want I can send you the complete code so that you can also implement it. Do let me know. Thanks Ruchita Sharma. -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Abhimanyu, Can you please tell me how to implement join table? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi First of all sorry that I couldnt check the forum yesterday then I want to know is it that 1)the group of a particular user is been decided by his type? I just want to know whether a particular group is decided by a particular type? 2)If possible can you send me all the fields 3) " Ruchita:Please tell me how to work with join table?" Are you asking me about association or asking me about querying" -- 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 -~----------~----~----~----~------~----~------~--~---