Thursday 15 January 2015

ruby on rails - railstutorial.org guide - Name Error in "has_many through" Model; Uninitialized Constant User::Relationship -


Text after "div class =" itemprop = "text">

I am working through Michael Hartl who is able to have_many working through creating a Twitter-like app with the user I am: Relationships, but wrong continuous start when I try to load a page that invokes any type of "follow" method

This is my user model:.

  class user & lt; ActiveRecord :: Base has_many: Tweets have_many: relationships, foreign_key: "follower_id", dependent: deleted has_many: followed_users, through: relationships, source: has followed :_over_with_many: reverse_relationships, foreign_key: "followed_id", CLASS_NAME: "relationship" Dependent: Through the followers: source: reverse_relationships, deleted: has_many: follower   

And this is my relation model:

  class relation & LT; ActiveRecord :: base is_to: follower CLASS_NAME: "user" belongs_to: followed, CLASS_NAME: "user" verifies: follower_id, presence: true verifies: followed_id, presence: true params.require (: followed_id) end   

Here is the method which is the root of the error:

  & lt;% as long as the current_user == @ user% & gt; & Lt; Div id = "follow_form" & gt; & Lt;% if current_user.following? (@ User)%> & Lt;% = Render '% unfollow'% & gt; & Lt;% else% & gt; Adhere to the & lt;% = Render '%' & gt; & Lt;% end% & gt; Feed in   

:

  def the following (other_user) relations.find_by (followed_id: other_user.id)? End   

and the error I get is:

  error in user name # showing undefined constant user :: relationship   

My paths are set as follows: / P>

  Project1 :: application.routes.draw is root: 'user # index' '/ log_in' = & gt; get receive. 'Session # log_in', such as: log_in get '/ log_out' = & gt; 'Session # log_out', such as: Log-Out Resource: Tweets Resources: Relationship Resources: Users Receive Members: The End, Followers of Followers   

was a very similar problem, T seems to be correcting all my plural right, based on Heart's guide and what else have I read.

Does anybody know why the name is showing error? Users: Why do you want to start relationships when it realizes that simple relationships are from any user, and both are in different models?

Thanks for any help! This is driving me crazy

It seems that the problem is with your relationship.rb file. Check the name of file and location: app / model / relation. RB

The error indicates that your user.rb class does not see relationship.rb. RB

No comments:

Post a Comment