Jump to content

The ultimate community for Ruby on Rails developers.


Model Design

  • Please log in to reply
1 reply to this topic

#1 tewing10



  • Members
  • 1 posts

Posted 05 December 2013 - 07:12 PM

I'm fairly new to Rails so I don't have as much knowledge on webapp design as I wish I did.


So the main use case for this Rails app is that a user comes to the root page, uploads an image to search for, fills out a few more search parameters, then clicks Search. The users request gets added to the DB and there will be another application running asynchronously that will queue up new rows added to the DB to perform long running searches (the search is actually facial recognition against another DB). The user gets sent to a Wait page where they can continually check the status of his or her search. Once their search is ready they can click on it and will be sent to a Results page where they can review the results of the facial recognition search.


So for my initial guess of the data I broke this into three Models: SearchDetail, SearchRequest, and SearchResult.


SearchDetail holds the path to the image field, and fields for the rest of the parameters.

SearchResult holds a vector of information from the search

SearchRequest has a one-to-one relationship with both SearchDetail and SearchRequest, status field, and session ID field (so it can be connected to the proper user)

*I also attached this for better visualization


It seems like I would only need a create for SearchDetail, show for SearchRequest, and show for SearchResult, rather than whole a scaffold for each one. So my question is, is this a decent design?


Attached Thumbnails

  • InitialGuess.PNG

#2 stevieing



  • Members
  • 40 posts

Posted 06 December 2013 - 11:18 AM

You can actually do this using a single resource. I have done this myself for a search based on the the following tutorial http://railscasts.co...ch-form-revised.


So for example you would have searches/new which would be a form where you would enter your search details.This would be submitted using an http POST request. The create action would then submit the details of the search to a a database. The user would then be redirected to the update page which would in all likelihood use some kind of Ajax functionality to poll the third party database. When the search is finished the update would be submitted and the user would be redirected to the show page with the results of the search.


It may even be a job for something like ember.js or another js framework.


Those are just my initial thoughts so not necessarily the right way to do it but may give you some ideas.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users