Naming conventions for models in ruby on rails are overridden.Entity
User and Responder have many to many association between them.It is
expressed with has many through.
Following are the model files:
user.rb:
has_many :Usertoresponder
has_many :responder, :through => :Usertoresponder
responder.rb:
has_many :Usertoresponder
has_many :user, :through => :Usertoresponder , :dependent => :destroy
usertoresponder.rb:
class Usertoresponder < ActiveRecord::Base
self.table_name = ‘User_To_Responder’
belongs_to :user
belongs_to :responder
end
But when saving or getting responder through user there is a problem
occurring it says -
user.responder is not defined.
And the above problem is not occurring when its done using test case
but its occurring if its done through http request.
On 14 March 2011 05:44, Renuka [email protected] wrote:
Naming conventions for models in ruby on rails are overridden.Entity
User and Responder have many to many association between them.It is
expressed with has many through.
You’re not overriding naming conventions - you’re getting cases and
syntax wrong…
Corrected off the top of my head:
user.rb:
has_many :usertoresponder
has_many :responder, :through => :usertoresponder
responder.rb:
has_many :usertoresponder
has_many :user, :through => :usertoresponder , :dependent => :destroy
usertoresponder.rb:
class Usertoresponder < ActiveRecord::Base
self.table_name = ‘User_To_Responder’
belongs_to :user
belongs_to :responder
end
BTW What reason is there for not calling the class “UserToResponder”?
Yes class name can be UserToResponder , there is no reason to keep the
class
name usertoresponder.
Where are the syntax errors?
Same thing is working with test case