class Player < ActiveRecord::Base
attr_accessor :name, :rating, :team_name
def initialize(name, rating, team_name)
@name = name
@rating = rating
@team_name = team_name
end
end
我跑的时候
bundle exec rails console
并尝试:
a = Player.new("me", 5.0, "UCLA")
我回来了:
=> #<Player not initialized>
我不知道为什么Player对象不会在这里初始化.关于该怎么做/解释可能导致这种情况的任何建议?
谢谢, Mariogs
have no idea why the Player object wouldn’t be initialized here
class Player < ActiveRecord::Base
attr_accessor :name, :rating, :team_name
def initialize(name, rating, team_name)
super
@name = name
@rating = rating
@team_name = team_name
end
end
class Player < ActiveRecord::Base
attr_accessor :name, :rating, :team_name
def initialize(name, rating, team_name)
@name = name
@rating = rating
@team_name = team_name
end
end
我跑的时候
bundle exec rails console
并尝试:
a = Player.new("me", 5.0, "UCLA")
我回来了:
=> #<Player not initialized>
我不知道为什么Player对象不会在这里初始化.关于该怎么做/解释可能导致这种情况的任何建议?
谢谢, Mariogs
have no idea why the Player object wouldn’t be initialized here
class Player < ActiveRecord::Base
attr_accessor :name, :rating, :team_name
def initialize(name, rating, team_name)
super
@name = name
@rating = rating
@team_name = team_name
end
end