On Thu, Apr 7, 2011 at 4:50 PM, Luka Stolyarov <li...@ruby-forum.com> wrote:
> Hello. I have a strange issue I can't figure out: > > In routes.rb I create this route: > > > map.connect('/api/v2/store/individual_offer/:offer_id', { > :controller => '/api/v2/store', > :action => :individual_offer , > }) > > Then, in the view I generate a url in this way: > > url_for(:controller => '/api/v2/store', :action => :individual_offer, > :offer_id => offer[:id]) > > What the generated url ends up looking like is this, though: > > lukka.local:7000/api/v2/store/individual_offer?offer_id=43, which > results in url getting associated with a different route from the one I > mentioned above. > > This is the very first route pointing to controller '/api/v2/store', so > it should be tried first. Did anyone encounter such issue before? I'm > using Rails 2.3.11. > > Thanks! > Luka > The views url_for is doing exactly what it thinks you want. By passing :offer_id in with the hash it is treating it as a parameter that you want tacked onto the url string. If want you want is this: lukka.local:7000/api/v2/store/individual_offer/43 then you would need to change your view to pass in object of individual_offer into url_for. url_for(@individual_offer) B. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.