我无法加载这些灯具,我不知道为什么。花了几个小时来解决问题并开始认真质疑我对现实的把握。所以我转向这里,希望有人指出错误,希望最小的嘲笑。
我尝试过与api-docs描述相同的方式并与authlogic文档结合使用。我在SO上找到的帖子都没有任何帮助。
使用ruby 1.9.2-p180
one:
id: 0
username: testuserone
email: whatever@whatever.com
password_salt: <%= salt = Authlogic::Random.hex_token %>
crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("benrocks" + salt) %>
persistence_token: <%= Authlogic::Random.hex_token %>
posts: one, two
two:
id: 1
username: testusertwo
email: test@gmail.com
password_salt: <%= salt = Authlogic::Random.hex_token %>
crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("benrocks" + salt) %>
persistence_token: <%= Authlogic::Random.hex_token %>
posts: one, two, valid_post
one:
title: First valid Awesome post
content: Clearly awesome content
user: one
two:
title: Second valid Awesome post
content: Clearly more awesome content
user: one
valid_post:
title: Awesome post
content: Clearly awesome content
user: one
empty_post:
title:
content:
user: one
ActiveRecord::Schema.define(:version => 20110527132832) do
create_table "posts", :force => true do |t|
t.string "title"
t.string "content"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
end
create_table "users", :force => true do |t|
t.string "username"
t.string "email"
t.string "crypted_password"
t.string "password_salt"
t.string "persistence_token"
t.datetime "created_at"
t.datetime "updated_at"
end
end
class Post < ActiveRecord::Base
cattr_reader :per_page
@@per_page = 3
default_scope :order => 'created_at DESC'
validates :title, :presence => true
belongs_to :user
end
class User < ActiveRecord::Base
attr_accessible :username, :email, :password, :password_confirmation
acts_as_authentic
has_many :posts
end
来源'http://rubygems.org'
gem'rail','3.0.7' gem'will_paginate','3.0.pre2' 宝石'authlogic' 宝石'漂亮发电机' 宝石'sqlite3' 宝石'factory_girl_rails' 宝石'faker' gem“mocha”,:group =&gt; :测试
答案 0 :(得分:0)
我很长时间没有使用过灯具,但我认为你不需要在userss.yml中描述这种关联,因为你已经在posts.yml中这样做了。尝试删除这些行。
答案 1 :(得分:0)
事实证明,当我迁移测试数据库或者我给所有与用户不同的帖子名称时,它开始工作:user_one,:user_two