Ruby on Rails Monday, October 12, 2015



On Saturday, 10 October 2015 15:57:25 UTC-4, Ruby-Forum.com User wrote:

I am building an E-commerce website on ruby on rails from scratch.

My product belongs to a subcategory which in-turn belongs to a category.

My filters partial include multiple check-boxes for
category,subcategory,additional_category(Like hand made clothes,factory
built etc.),lifestyle(relaxed,corporate etc) and
cloth_material_type(this has around 30 options)

I am sending an array for each of these 5 cases to the backend to search
through the associations.

Now when a non logged in user reloads the page the filters set by user
resets to default.

To avoid this I have three options in mind.

Option 1. Store the filter values set by the user in the cookies which
is fast.But it might slow down the user's browser.

Option2 . Store the values in a session using ActiveRecord::SessionStore
gem which will increase the size of session for me to 65K but would slow
down the application.

Option 3 .Using jquery modify/create document.url options so that every
filter option gets appended to the document.url and on reload I get the
parameters set by the user for filtering.But this looks very cumbersome
to implement.


This isn't terribly difficult to implement, especially if you're reloading the page when the products are filtered - just make the form use `GET` and the URL will have all the user's selections. This is also helpful for users who want to bookmark or share the filtered list, as the entire state of the view is encoded in the URL.

--Matt Jones
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/dc201497-ff44-4bc5-b0a8-b3037951cdb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment