0
다음 사용자를 위해 새로운 앱을 만들고 있는데 문제가 생겼습니다. 이건 내 오류입니다 :Ruby on Rails NameError
* 내 사용자 모델
class User < ActiveRecord::Base
attr_accessible :pass, :username
# Who am I following?
has_many :following_relations, :foreign_key => :follower_id
has_many :following, :through => :following_relations
# Who am I followed by?
has_many :follower_relations, :class_name => "Relation", :foreign_key => :following_id
has_many :followers, :through => :follower_relations
validates :username, :pass, :presence => true
validates :username, :pass, :length => { :minimum => 4 }
validates :username, :uniqueness => true
def self.login(username,pass)
user = find_by_username(username) and user = find_by_pass(pass)
if user.nil?
return nil
else
return user
end
end
end
* relaion 모델
class Relation < ActiveRecord::Base
belongs_to :follower, :class_name => "User"
belongs_to :following, :class_name => "User"
end
* 액션 : 내 코드에서 사용자 :: FollowingRelation을 찾을 수 있습니다
NameError in Welcome#sucess
Showing ../welcome/sucess.html.erb where line #13 raised:
uninitialized constant User::FollowingRelation
Extracted source (around line #13):
10: <br />
11: Following
12: <ul>
13: <% @user.following.each do |u| %>
14: <li><%= link_to u.username, u %></li>
15: <% end %>
16: </ul>
성공
def sucess
@user = User.find(params[:id])
@relation = Relation.new
end
내가 루비 레일에 새로운, 그래서 저를 도와주세요 :)
내가 새로운 오류가를 :)) 그러나 나는 그것을 고칠 수 있다고 생각한다. 고맙습니다!! – mayoneQD
그것은 작동합니다! 정말 고맙습니다 – mayoneQD