Seems like it would be a lot easier to just have the logic in the 
controller.

Right now you have the logic in the routes, then you'll also need logic in 
 the controller to check whether params[:id] or params[:site_photo_id] 
exists.

If you have just one route and move the logic to the controller, you'll 
accomplish what you're looking for, and avoid repeating logic in routes and 
controller.

*routes.rb*

match "/photos/:id", :to => "photos#show", :as => "photo", :constraints => 
{:id => /.*/}

*photos_controller.rb*

def show
  if params[:id] =~ /\d{2}\.\d{2}\..*/
    # it's a site_photo_id
  end
end

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/7WL0cu_v1jcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to