Topic: Modeling Database on RoR

Here my questions about how should I should take care about the database management. I am new to newbie and coming from PHP and MySQL. Now I have a database of 3NF has follow

Client                          MusicInterest
P c.User                      P mi.ID
   c.Pass                         mi.descriptions
   c.emails

now I want to keep track when it was modify by the user. To solve this issue i created a third table which respect the 3NF

MusicInterestManager
F,P    mi.ID
F,P    c.User
         mim.modifyAt
         mim.reasonModify

Now this is using mySql for database, but i am not sure how to manage this in RoR, should I worry about this, or have a special field directly in the c.User integrating the interest field and somehow the RoR has a built in feature that allow me to track anytime modification are done??

Thanks in advance

Last edited by jseb (2012-07-03 23:48:35)

Re: Modeling Database on RoR

This sounds like has_many :through would work for this. http://guides.rubyonrails.org/associati … ssociation

Re: Modeling Database on RoR

So it would be has follow??

class Client < ActiveRecord::Base
  has_many :MusicInterestManagers
  has_many :MusicInterest, through => :musicInterestManagers
end

class MusicInterest < ActiveRecord::Base
  has_many :MusicInterestManagers
  has_many :Clients, through => :musicInterestManagers
end

class MusicInterestManager < ActiveRecord::Base
  belongs_to :MusicInterest
  belongs_to :Client
end

Re: Modeling Database on RoR

Close:

class Client < ActiveRecord::Base
  has_many :music_interest_managers
  has_many :music_interests, through => :music_interest_managers
end
class MusicInterest < ActiveRecord::Base
  has_many :music_interest_managers
  has_many :clients, through => :music_interest_managers
end
class MusicInterestManager < ActiveRecord::Base
  belongs_to :music_interests
  belongs_to :client
end

Re: Modeling Database on RoR

Thanks

Re: Modeling Database on RoR

Not sure if you can help!

But it almost work! At the moment i am using Active_admin to allow to manage the merge but when it comes to musicinterestmanager i get the following error. Anybody knows why?

Showing /home/jean/.rvm/gems/ruby-1.9.3-p194/gems/activeadmin-0.4.4/app/views/active_admin/resource/index.html.arb where line #1 raised:

uninitialized constant ActivitiesManager::Customers
Extracted source (around line #1):

1: render renderer_for(:index)
Rails.root: /home/jean/rail/wyw

Application Trace | Framework Trace | Full Trace

Re: Modeling Database on RoR

Get Facebook fans, buy facebook fans, get facebook likes, buy facebook likes. Delivering likes to fan pages and website and tracking progress at http://www.socialkik.com/