Implementing virtual concepts in rails -


my question more of general nature.

i know scopes in rails running concept not able wrap my head around

i have few tables in db - customers, products, sales etc. , have various sales persons logging in view sales, etc. want implement concept of "my" when sales person comes in able see sales, customers, products sold etc. my.customers or my.sales or my.territories etc.

how can implement this? how can prefix "my" onto customers, sales etc achieve elegantly ?

guidance appreciated.

thanks,

you should take at:

http://guides.rubyonrails.org/active_record_querying.html

this use associate , manage user sees, , how access in controllers/views. example:

class client < activerecord::base   has_many :sales end  class sale < activerecord::base   belongs_to :client end 

this make client has many sales, , can access using client.first.sales... example.

to make my instead of user.first, can use:

private  def   user.first end 

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 -