I am learning rails and am toying with a simple web-app that integrates with flickr to search photos based on user given criteria and store the query in a search history table.
I am seeking the best or ‘rails’ way of handling this. Should I setup a controller and non-resource routes that handle the search and store the data in a custom table; or should I create a resource for queries with a resource route and an additional path for search?
My thoughts:
In config/routes.rb:
Create a
SearchController:In app/controllers/search_controller.rb:
For example, a query for “apples” would appear as: http://example.com/search/apples
You can generate links to queries with:
search_path('apples')