Rails Overall Architecture Best Practices -


i'm interested see rails veterans on stack overflow have this.

basically, rails newb, , no "formal" background in programming, 1 of biggest challenges has proper architecture. how know right or better build app are?

i love see resources are.

i know basic ones - lot of these don't give me high level architecture overview want:

http://www.amazon.com/agile-development-rails-third-edition/dp/1934356166/ref=cm_lmf_tit_7 http://www.amazon.com/ruby-programming-language-david-flanagan/dp/0596516177/ref=cm_lmf_tit_3 railscasts

here's quick example:

say i'm building rails app has merchants , shoppers - each set of users has own authentication, different permissions, etc. proper build single app or multiple communicate through apis? there added benefit multi-app abstraction?

thanks!

this not easy question. complete answer largely depend on project.

if starter i'd recommend keep in 1 app, have enough "separation" using models wisely. it's hard immagine scenario complexity introduced inter-app communication beneficial.

in example should ask wether it's better use 1 single parent model merchants , shoppers or 2 separate models.

in former case can consider sti:

  • user (main class, defined class user < activerecord::base)
    • merchant (defined class merchant < user)
    • shopper (similarly class shopper < user)

google sti further details.

then in controllers/view can check permissions quickly, example:

if user.class == merchant   do_something else   do_something_else end 

similarly 2 classes might authenticate different algorithms. might include "standard" authentication in base user class , specialize in subclasses, if required.

cheers,


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -