I am having a problem with structuring rails application. Let’s say that I have a Style model and I want to have listed 5 featured ones on my page root (/), and browse option where I can set listing from the oldest to the newest and vice versa.
http://example.com/ – five featured
http://example.com/styles/newest –
all newest http://example.com/styles/oldest – all oldest
How do I code the controller and routes? I’ve tried separate controllers for five featured and for all with if statement ( something like if params[:order] == ‘oldest’ then @styles = Style.oldest), but this doesn’t seem to be either working or logical.
Add two custom routes.
Routes.rb
StylesController.rb
Suggestion: Keep it simple.