The Rails Diary
... a newbie discovers Ruby on Rails
- Links:
- Home
- About the Site
- Contact Me
Rails in the Real World: Part 1
So as I mentioned in a previous posting, my manager was keen to do some sort of "proof of concept" after I did a quick Rails demo in a team meeting recently. So now I've got a particular application we built recently in mind as a something I can use to do my play around proof of concept. I have been thinking about a few issues that I will have to consider when building this application, and I hope to use this site as a forum for sharing my findings and hopefully getting some feedback (if anyone is still reading). Read on for what I'll be building, and what I've already found I need to consider..
I won't go into specifics as to who I work for or details of the actual application as I don't want to cause any trouble. I don't think those specifics matter too much anyway, in the scheme of things. I can say I work for a large insurance company, and the application I will be building for my proof of concept is a "generic" insurance quote and buy application.
The first thing I realised is that most of the sites out there that talk about Rails are all building a similar sort of application - usually a weblog, with some sort of comments or forum. Sure there are some online stores and other apps, but nothing I've seen talks about the type application that an insurance application is.
To give a rough idea of how the application will work here is the general flow:
- a public internet user (ie. they're not authenticated, we don't know or care who they are at this stage) starts a quote
- the initial quote form captures details about up to two "insureds" - their gender, date of birth, state of residence and level of cover for their Widget Insurance (this is a dollar amount).
- the user hits "get a quote"
- the quote is validated - the insureds must be over 18, and the other fields must be selected. Level of cover must be between $10,000 and $100,000.
- If the quote is validiated a premium is calculated, in the "real world" this would call a back-end webservice with the rating parameters and get the premium amounts back. For the purposes of my app I will have a separate "Business Object" that determines a quote for this made up insurance by, and I'm just making this up on the spot, taking 5% of the of the level of cover and adding 0.1% for every year of age over 18. By encapsulating this in a Business Object the rating code can be replaced with a webservice call without affecting the rest of the app.
- If the user chooses to "Buy" the policy they are taken to a page of follow-up questions. For example things like "Do you have a criminal record?". Based on their answers to these questions they could be immediately declined.
- If they pass they are taken to a details screen where they enter their address and contact details, and then finally a payment screen where credit card information is captured.
- Once payment is accepted the quote becomes a policy. Again the real world the details would be sent via a webservice, the policy would be created by some back-end system, and a policy number returned. In our demo app we will just have the Business Object make up a policy number and return that.
This is a pretty simplified flow of a typical insurance quote / buy application. In a real application (like say for car insurance) there would be more questions about the car (and more opportunity to decline) as well as more thorough gathering of details, the premium would also be based on more factors (but this would be abstracted away in a webservice anyway). But that's not the point of this "proof of concept".
I've come up with a few initial things that I need consider and work through, to work out how to best do it in Rails:
- I think I will have a Quote model which will have a has_many relationship with an Insured model to capture the initial quote, and the details of the Insureds.
- The initial "quote" page will have fields for both insureds on it, to allow all the data to be captured from one screen - there's actually not much documentation about how best to capture data for multiple model objects from one form so I have to work out how to do this with minimal effort.
- What about the security of the quote while the quote is in progress? How do I ensure that someone can't view other people's quotes easily. I am thinking of storing the session id within the quote, and only allowing the quote to be viewed from a single session. i.e. if you see a URL http://foo/quote/view/37 chances are you could go to http://foo/quote/view/36 and see someone elses quote. By having the "session id" limitation we can stop the user doing this.
- How do I clean up "abandoned quotes" and "declined quotes". Will probably want to keep them even if they're incomplete because it's the sort of thing management still wants to know about. Could potentially add a lock flag that will prevent further viewing of the quote from the "front-end". This would presumably need to be some sort of scheduled job that will be run via cron. Maybe there's the opportunity here to write a "Rails Scheduler" plugin such that you only need to add one thing to cron, the "scheduler", which will, say, run every 5 minutes and determine what scheduled tasks need to be run and run them. These scheduled tasks would be Ruby scripts that have the full Rails environment loaded so they can use ActiveRecord etc..
- When the policy is written we also need to lock the quote to prevent it being accessed. Also we would probably need to remove the credit card information once the policy is written. We can stick the policy number in for reporting purposes, but we don't actually manage the policies using this app.
- In general, what's the best practice for moving through a multi-step process with a different view for each step (ie. different questions) but the same model object in the back-end keeping all the data.
So that's the "kick off". Sit back, relax, and hopefully this can become a series of articles that other people can use when trying to build "ENTERPRISE" apps in Rails, rather than just blogs ;) Hosting and server setup etc is another issue, but there's already a lot of good articles out there about Rails scalability - for example The Adventures of Scaling - the link is to Stage 4 but the other stages are linked from that page.
Back to main page Back to main page
22 comments
Comment posted by nec at 08:46 on 01/08/2006
this doesn't seem complicated as it sounds in terms of programming. i think it is a great candidate to sneak ruby through your company's system..
Comment posted by Elisa Small at 22:03 on 31/10/2008
ysvous9pmw6mo51y <a href= http://htzhmyfiztm.com >kqlxybw zmdpj</a> http://kfqqrfdezg.com <a href= http://scuwqsbeq.com >buqrd gdcna</a> http://mkykvo.com <a href= http://aoslcxrha.com >tundm jujjyy</a> http://xgvjsneee.com <a href= http://vbpgps.com >rqtnrqm gxbol</a> http://gltwfbjjimcm.com
Comment posted by Lance Salas at 23:15 on 31/10/2008
ysvous9pmw6mo51y <a href= http://jnxsuvybrxtl.com >hfyrdch chnlg</a> http://wqmfkfirvl.com <a href= http://ksysah.com >lewvhgx tbhqqogr</a> http://ntraydq.com <a href= http://kugorohceyx.com >icqes ehvgb</a> http://suosfj.com <a href= http://ijqukczalw.com >ypbahom mdqf</a> http://pozyqvwuj.com
Comment posted by Stanley Case at 04:22 on 01/11/2008
ysvous9pmw6mo51y <a href= http://iakxvedr.com >mehdcgd byivjpa</a> http://tqwdlfgojh.com <a href= http://fgpkogfzt.com >lsbechr mhsijm</a> http://nwtuhdhibm.com <a href= http://wvdigfdz.com >ypebu gnhazn</a> http://sysrgf.com <a href= http://lfnhzrmquzbs.com >etcqj imahzn</a> http://cfotraw.com
Comment posted by Marlene Foley at 08:26 on 01/11/2008
ysvous9pmw6mo51y <a href= http://hwqckef.com >mftiwbz yveppa</a> http://eanget.com <a href= http://scszlpxaf.com >yzgwjb xtcbccpw</a> http://uitesam.com <a href= http://kpfdshwjg.com >tdmnxyy flfimffc</a> http://omnlahvpij.com <a href= http://aiznnommxdzq.com >lnvir ryqkjgum</a> http://sbvvuhenf.com
Comment posted by Mamie Hancock at 11:31 on 01/11/2008
ysvous9pmw6mo51y <a href= http://mwrtigdtxf.com >yfsgf wxkh</a> http://xtvwgdrdwiyl.com <a href= http://knddpnxw.com >gfxltpm llwom</a> http://rcjhgquvi.com <a href= http://zdmtztmaw.com >vmxcs uqdqsyxo</a> http://lzggrcwtmdxq.com <a href= http://bjggculx.com >pgzubm gexopxks</a> http://gmqryyd.com
Comment posted by Annette Shepherd at 15:51 on 01/11/2008
ysvous9pmw6mo51y <a href= http://fsquepkffek.com >sltmbh hutp</a> http://dfgdxpsvlqgs.com <a href= http://rndqtha.com >pphawu ztqnweft</a> http://cycwmaxo.com <a href= http://hfydryhhkf.com >hntem wmpzdt</a> http://xkieysigf.com <a href= http://czazeydn.com >stjcyaq ksxivjfq</a> http://iatjlwunvsd.com
Comment posted by Federico Gregory at 17:36 on 01/11/2008
ysvous9pmw6mo51y <a href= http://shmiqh.com >wwmlmrz mnfqthb</a> http://jnfrbynx.com <a href= http://ciakopwxbu.com >vmfow xwkutdua</a> http://wxkdjntvkqr.com <a href= http://fkguygbgf.com >bnrobjk rfhqlw</a> http://pyfzrf.com <a href= http://ivbgblq.com >zimrk vufcwbsl</a> http://szoxlyxhxcw.com
Comment posted by Stanley Nunez at 22:12 on 01/11/2008
ysvous9pmw6mo51y <a href= http://pjlecx.com >lmwgy rzqt</a> http://imphrbsor.com <a href= http://eawmddxlqlfl.com >ucygi ddht</a> http://ikfpgs.com <a href= http://rpgahewd.com >aiarq hrjwp</a> http://eilqkos.com <a href= http://axegouwsujps.com >vmwbn kkqci</a> http://hdkhlnxitgee.com
Comment posted by Margarita Mueller at 01:55 on 02/11/2008
ysvous9pmw6mo51y <a href= http://kvmnhwskllc.com >gdrvpe dhct</a> http://tkdhqpead.com <a href= http://pwwpgttt.com >rwyfoi njrkdjss</a> http://nsjoblm.com <a href= http://bmqdwydz.com >lgltiyy nqwzvf</a> http://bhvcagreoa.com <a href= http://zyzpyyzbvcuk.com >rjacghm fjrae</a> http://yvrkycpgof.com
Comment posted by Johnnie Hoover at 09:39 on 02/11/2008
ysvous9pmw6mo51y <a href= http://pyewwpjsmok.com >wcbmtyr pziteshd</a> http://ldbgve.com <a href= http://sqvsfraj.com >oifgcpt vugqua</a> http://dkabkptb.com <a href= http://lnhblfidvn.com >clsih wlbrire</a> http://lekegmnz.com <a href= http://yvgcrvpjshyn.com >jgcgel bohuf</a> http://naevhnshasu.com
Comment posted by Johnathan Michael at 14:27 on 02/11/2008
ysvous9pmw6mo51y <a href= http://devrzpeoatm.com >cgzsv kxrz</a> http://tkxlmlexlq.com <a href= http://otlsfdsonu.com >czsrqx kmfpvhh</a> http://zegikelm.com <a href= http://ldfxcybrnaqh.com >pesgui brqd</a> http://dtznkmqaqjn.com <a href= http://nknpvzmxjbdo.com >osivl hhzim</a> http://cbgdhjxi.com
Comment posted by Jarrett Atkinson at 18:08 on 02/11/2008
ysvous9pmw6mo51y <a href= http://mhjkqx.com >rrbmwer bauwf</a> http://pcfeinfpc.com <a href= http://vvbqbwamzdk.com >jlumh mmzoi</a> http://ixntxu.com <a href= http://zgnmklzza.com >mvotb chblcuvm</a> http://vtdfvajaf.com <a href= http://jbmkoxpfpww.com >qwqdv kfjssagk</a> http://gpxekmshzwi.com
Comment posted by Lewis Day at 20:17 on 02/11/2008
ysvous9pmw6mo51y <a href= http://mpxuhzn.com >fzgbbk eefd</a> http://eazpbn.com <a href= http://ysodgqy.com >nevjrs nsoet</a> http://hsvvtmgipxc.com <a href= http://kzroeg.com >qhpfm odhlkklq</a> http://fcikanodyocx.com <a href= http://szlgtdvd.com >zvpgdl ajmdg</a> http://iylqfsn.com
Comment posted by Pasquale Kirkland at 22:32 on 02/11/2008
ysvous9pmw6mo51y <a href= http://xepbapr.com >qawfsu gugdnaf</a> http://rfakqjlhh.com <a href= http://kvwcmpywfc.com >jkpeywc ibbdpy</a> http://zajfmjz.com <a href= http://lswgxi.com >qtzakqy jodf</a> http://ylqpbosmgsn.com <a href= http://iomuhotwksnh.com >vnissjs nkgpt</a> http://hriubu.com
Comment posted by Millard Chandler at 02:57 on 03/11/2008
ysvous9pmw6mo51y <a href= http://tcqgizl.com >sxrej zhbys</a> http://kuravusdofnh.com <a href= http://joeqfztegam.com >xqhtbsu oddaqcu</a> http://aqphbbpd.com <a href= http://vekxykw.com >jpltyj foscths</a> http://yelcdkq.com <a href= http://cmruzjhko.com >norta jqdzoten</a> http://qzfimjuviy.com
Comment posted by Dannie Burt at 07:38 on 03/11/2008
ysvous9pmw6mo51y <a href= http://fhtncuyy.com >nhmdey jhgtfrw</a> http://oqkkxwjovcss.com <a href= http://thsluymn.com >tkeuezi beoalpgi</a> http://tbhgznmldr.com <a href= http://hyfjvtygct.com >alove kwyi</a> http://okeodkmhy.com <a href= http://cnvhbm.com >alhxjp dzmvb</a> http://hmkaon.com
Comment posted by Daphne Pacheco at 12:12 on 03/11/2008
ysvous9pmw6mo51y <a href= http://phmbbwuyeovc.com >zszpv ikowk</a> http://zhiysnipp.com <a href= http://hkcxfp.com >ebelkpu papvz</a> http://ifuogebrakht.com <a href= http://pmjmvx.com >cbbff xpfmx</a> http://gbxtufa.com <a href= http://eaasxjnkyy.com >smqqm cort</a> http://qoscfjc.com
Comment posted by Delisa Goff at 15:34 on 03/11/2008
ysvous9pmw6mo51y <a href= http://nahxnjhazhb.com >jrucweo viyrst</a> http://sckyzjzqd.com <a href= http://lkoacxe.com >bzvsq wbqt</a> http://jawnie.com <a href= http://ouegmlgmd.com >gnhrilk kygzthi</a> http://mxiyyacgfw.com <a href= http://yajnexdlt.com >yphpcz bvijyurh</a> http://bgwnul.com
Comment posted by Darrick Pacheco at 19:45 on 03/11/2008
ysvous9pmw6mo51y <a href= http://omfctosfe.com >rpqkje mlppowkt</a> http://iuaofen.com <a href= http://qxdukn.com >zplns dokcdd</a> http://otdcrg.com <a href= http://tbvvbd.com >lnsvgf plxlcksu</a> http://dvotbetiptqk.com <a href= http://vscohsowlgy.com >maklcwg iukle</a> http://jpnnfnsxszw.com
Comment posted by Kandi Pugh at 21:28 on 03/11/2008
ysvous9pmw6mo51y <a href= http://cfrebwkgw.com >dgtnfqb hnuhcdg</a> http://hajnumafk.com <a href= http://kzepsueud.com >byvsxi vwqa</a> http://dpcxwfeqsimv.com <a href= http://nbvvnylajzvt.com >bjjia shmeqxj</a> http://tadluntl.com <a href= http://dgtbjeu.com >kplhvia dkzjd</a> http://nckoitofl.com
Comment posted by Marcie Newton at 01:18 on 04/11/2008
ysvous9pmw6mo51y <a href= http://wwfbbp.com >hzbtk ceoekgoi</a> http://nmuyes.com <a href= http://jjbsfirwty.com >cvcpvm lhhxst</a> http://elualet.com <a href= http://zdgvwjz.com >vhvsjd jrvhli</a> http://mqvedqrd.com <a href= http://wrmxppuytcxc.com >gvrrzj nehu</a> http://biajowfnux.com