What the Ruby Association

Here a final questions, not sure if you may know. I installed activeadmin has a gem and it allow me to manage any customer, interest and a manager to control when this one is expired or so

It has the following associations

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

How many music_interests does it belong to. The fact that you have used the plural suggests it belongs to several, but that does not seem likely.

  belongs_to :client end

But when installing a resources for MusicInterestManager I get the following error!

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

ActivitiesManager and Customers? Where did they come from?

How are you getting on with the tutorials?

Colin

Just a side-note here. I really STRONGLY recommend that you don't jump into an "easy" admin tool like this until you have worked out the very basic way that Rails works. These toolkits introduce a second level of abstraction over Rails, and while they can jump-start a site and give you 90% of what you need right out of the box, they also keep you from learning how the system works, which will rear up and bite you later. Further, they can often make that last 10% nearly impossible to attain, and complicate the process of learning even more.

Just my two pfennigs here.

Walter

Colin Law wrote in post #1068577:

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

How many music_interests does it belong to. The fact that you have used the plural suggests it belongs to several, but that does not seem likely.

uninitialized constant ActivitiesManager::Customers

ActivitiesManager and Customers? Where did they come from?

How are you getting on with the tutorials?

Colin

Sorry the example customer and music_interest_manager was just an example, the customer and activities_managers is my actual names. Here the real test lookup

class ActivitiesManager < ActiveRecord::Base   belongs_to :customers   belongs_to :activities class Activity < ActiveRecord::Base   has_many :activities_managers   has_many :customers, :through => :activities_managers class Customer < ActiveRecord::Base   has_many :activities_managers   has_many :activities, :through => :activities_managers

I am just using this tools for administrative backend feature not the front end. I am just curious the way I wrote it down to see if its correct or if something else is wrong with my style of writing ruby.

Colin Law wrote in post #1068577:

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

How many music_interests does it belong to. The fact that you have used the plural suggests it belongs to several, but that does not seem likely.

uninitialized constant ActivitiesManager::Customers

ActivitiesManager and Customers? Where did they come from?

How are you getting on with the tutorials?

Colin

Sorry the example customer and music_interest_manager was just an example, the customer and activities_managers is my actual names. Here the real test lookup

class ActivitiesManager < ActiveRecord::Base   belongs_to :customers

If you followed my advise and worked through some tutorials you might not make so many silly mistakes. How many customers does an ActivitiesManager belong to? The fact that you have said belongs_to customers suggests that it belongs to more than one customer, which is unlikely.

  belongs_to :activities

Ditto

Colin

Colin Law wrote in post #1068584:

used the plural suggests it belongs to several, but that does not seem

example, the customer and activities_managers is my actual names. Here the real test lookup

class ActivitiesManager < ActiveRecord::Base   belongs_to :customers

If you followed my advise and worked through some tutorials you might not make so many silly mistakes. How many customers does an ActivitiesManager belong to? The fact that you have said belongs_to customers suggests that it belongs to more than one customer, which is unlikely.

  belongs_to :activities

Ditto

Colin

It his has follow

Customer Manager Activity John John 1 2012-01-05 1 Soccer Josh John 3 2012-01-07 2 Hockey                       Josh 2 2012-01-05 3 Footbal

The purpose is to keep track of everything

So there the model Customer has_many Manager Manager belongs to Customer Manager belongs to Activity Activity has_one Manager

Does this make sense?

How are you getting on with the tutorials?

Colin

Thanks it make more sense!!!

So my structure should be as follow: class ActivitiesManager < ActiveRecord::Base   belongs_to :customers   belongs_to :activities class Activity < ActiveRecord::Base   has_one :activities_manager class Customer < ActiveRecord::Base   has_many :activities_managers   has_many :activities, :through => :activities_managers

I also read the entire book 3 time in the last 2 weeks http://ruby.railstutorial.org/chapters/

Thanks it make more sense!!!

So my structure should be as follow: class ActivitiesManager < ActiveRecord::Base   belongs_to :customers   belongs_to :activities

Please answer the question - how many customers does an activitiesmanager belong to?

class Activity < ActiveRecord::Base   has_one :activities_manager class Customer < ActiveRecord::Base   has_many :activities_managers   has_many :activities, :through => :activities_managers

I also read the entire book 3 time in the last 2 weeks http://ruby.railstutorial.org/chapters/

Reading it is not enough. Work right through it, typing and running the code on your PC, make sure you understand every single line of code. Do all the exercises.

Colin

Please answer the question - how many customers does an activitiesmanager belong to?

An activity manager can have multiple customer and repeat many time the same customer. but an activity manager can only have one to one activity

So it should be has follow class ActivitiesManager < ActiveRecord::Base   belongs_to :customers   belongs_to :activity class Activity < ActiveRecord::Base   has_one :activities_manager class Customer < ActiveRecord::Base   has_many :activities_managers   has_many :activities, :through => :activities_managers

Reading it is not enough. Work right through it, typing and running the code on your PC, make sure you understand every single line of code. Do all the exercises.

In term of exercise i have done up to chapter 9 so far

Please answer the question - how many customers does an activitiesmanager belong to?

An activity manager can have multiple customer and repeat many time the same customer. but an activity manager can only have one to one activity

So it should be has follow class ActivitiesManager < ActiveRecord::Base   belongs_to :customers

The belongs_to association implies a one to many association, so an activities manager can only have one customer as you have declared it here, and belongs_to :customers is not valid. It must be belongs_to :customer.

  belongs_to :activity class Activity < ActiveRecord::Base   has_one :activities_manager class Customer < ActiveRecord::Base   has_many :activities_managers   has_many :activities, :through => :activities_managers

Reading it is not enough. Work right through it, typing and running the code on your PC, make sure you understand every single line of code. Do all the exercises.

In term of exercise i have done up to chapter 9 so far

The has_many, belongs_to association is dealt with in Chapter 10. I suggest, once again, that you finish the tutorial before continuing with your application.

Colin