Ruby on Rails教程第6.3.4节

时间:2016-02-12 07:51:59

标签: ruby-on-rails ruby railstutorial.org

当我创建用户帐户时,我收到此警告。 这条消息意味着什么?

df1['date'] = pd.to_datetime(df1['date'])
df2['date'] = pd.to_datetime(df2['date'])
print df1
  type  sum       date
0   x1   12 2012-01-01
1   x2   10 2012-01-01
2   x3    8 2012-01-01
3   x1   13 2012-02-01
4   x2   12 2012-02-01
5   x3   55 2012-02-01
6   x1   11 2012-03-01
7   x2   10 2012-03-01
8   x3    8 2012-03-01

print df2
   total       date
0    122 2012-01-01
1    133 2012-02-01
2    144 2012-03-01

2 个答案:

答案 0 :(得分:0)

确保您的 user.rb 文件与完全相同

class User < ActiveRecord::Base
  before_save { self.email = email.downcase }
  validates :name, presence: true, length: { maximum: 50 }
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :email, presence: true, length: { maximum: 255 },
                    format: { with: VALID_EMAIL_REGEX },
                    uniqueness: { case_sensitive: false }
  has_secure_password
  validates :password, presence: true, length: { minimum: 6 }
end

答案 1 :(得分:0)

错误消息告诉您user.rb语法错误:

SyntaxError: /app/models/user.rb:6: syntax error, unexpected ':', expecting keyword_end
format: { with: VALID_EMAIL_REGEX }
      ^
/app/models/user.rb:7: syntax error, unexpected ':', expecting keyword_end
uniqueness: { case_sensitive: false }

您可能错过了,或关闭}

重温您的user.rb(尤其是第5-7行)并仔细检查它是否与example in the book完全相同。