Given this route: map.connect '':controller/:action/:object_name/:mailing/:check_state'', :defaults => {:mailing => ''0'', :check_state => ''0''} and the URL spec. here (embedded in a call to remote_function): :url => {:action => ''lookup_city_and_state'', :object_name => ''insured'', :mailing => mailing ? ''1'' : ''0'', :check_state => check_state ? ''1'' : ''0''} why do I end up with this generated URL (''artisan_qualifiers'' is the name of my controller): /artisan_qualifiers/lookup_city_and_state/insured/1 ? I would expect another / and a value for check_state. Thanks, Wes -- 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 -~----------~----~----~----~------~----~------~--~---
OK, it seems like if I remove the :defaults part of my route, then it works. Did :check_state get _completely_ ignored because the value for :mailing didn''t match the default value for :mailing? I won''t use :defaults ''til I understand this. Wes -- 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 -~----------~----~----~----~------~----~------~--~---
> map.connect '':controller/:action/:object_name/:mailing/:check_state'', > :defaults => {:mailing => ''0'', :check_state => ''0''} > > and the URL spec. here (embedded in a call to remote_function): > > :url => {:action => ''lookup_city_and_state'', :object_name => ''insured'', > :mailing => mailing ? ''1'' : ''0'', :check_state => check_state ? ''1'' : > ''0''} > > why do I end up with this generated URL (''artisan_qualifiers'' is the > name of my controller): > > /artisan_qualifiers/lookup_city_and_state/insured/1In your call, what is the value of mailing and check_state? I''d guess that mailing => 1 and check_state => 0, and since that is the default, Rails left it off since it''s not necessary. Be interesting to see the output of: :url => {:action => ''lookup_city_and_state'', :object_name => ''insured'', :mailing => ''0'', :check_state => ''1''} and see if you get this: /artisan_qualifiers/lookup_city_and_state/insured/0/1 -philip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip, This is something that I didn''t understand about routes. So if a value matches the default, it won''t be represented in the URL but the param will still get that value when the controller action is started, is that correct? WG -- 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 -~----------~----~----~----~------~----~------~--~---
If I do what I said above, then the URL is generated as stated, but then in the action, params[:mailing] is nil! Why? -- 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 -~----------~----~----~----~------~----~------~--~---
Alright - fuller disclosure - this is an AJAX call where I''m setting a query string as well. It''s a simple ZIP code lookup action. I''m setting the params that I know about up front as part of the URL and using the route to get those. However, for the ZIP code, which comes from the form, I''m setting that on the query string. Given the route above, and this call (the object_name variable has a value of ''insured'', the check_state variable has a value of ''0'') <%= text_field(object_name.to_sym, "#{attr_prefix}zip_code".to_sym, :size => 10, :maxlength => 10, :onblur => remote_function(:url => {:action => ''lookup_city_and_state'', :object_name => object_name, :mailing => mailing ? ''1'' : ''0'', :check_state => check_state}, :with => "''zip='' + encodeURIComponent(this.value)", :before => ''ajax_running = true; ajax_issues = false'', :complete => ''ajax_running = false;'')) %> Seems like in this case - where mailing is ''1'', check_state is ''0'', that the URL comes out as expected, but params[:object_name], params[:mailing], params[:check_state] all come in as nil. My guess is that the presence of the query string parameter screws things up if the URL isn''t completely specified (which seems to happen based on the defaulting rule). Weird. It''s not like the parameters in the URL and the parameters spec''d in the AJAX call _can''t_ coexist (they can if I don''t use defaults on the route). Well, I''m back to not defaulting for this guy. Thanks, Wes -- 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 if a value matches the default, it won''t be represented in the URL > but the param will still get that value when the controller action is > started, is that correct?Could be... I was just guessing :) Seems like a railish thing to do :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Take a look at my last post - do I need to do something in the route specification in order to allow for query string parameters? Wes -- 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 -~----------~----~----~----~------~----~------~--~---