2011-01-31 2 views
0

私は私のdeviseユーザーモデル(フルネームとユーザー名)にフィールドを追加しました。これは私のユーザーモデルです:カスタマイズされたdeviseがキュウリで失敗する

class User < ActiveRecord::Base 
    # Include default devise modules. Others available are: 
    # :token_authenticatable, :lockable, :timeoutable, :confirmable and :activatable 
    devise :database_authenticatable, :registerable, 
     :recoverable, :rememberable, :trackable, :validatable 

    # Setup accessible (or protected) attributes for your model 
    attr_accessible :email, :password, :password_confirmation, :username, :fullname 
    # attr_accessor :username, :fullname 
end 

私は私のビューでfullnameにアクセスできます。このエラーで

Scenario Outline: Creating a new account 
    Given I am not authenticated 
    When I go to register # define this path mapping in features/support/paths.rb, usually as '/users/sign_up' 
    And I fill in "user_email" with "<email>" 
    And I fill in "user_password" with "<password>" 
    And I fill in "user_password_confirmation" with "<password>" 
    And I fill in "user_fullname" with "<fullname>" 
    And I fill in "user_username" with "<username>" 
    And I press "Sign up" 
    Then I should see "Signed in as <fullname>" 

    Examples: 
     | email   | password | fullname | username | 
     | [email protected] | secretpass | man net | net | 
     | [email protected]  | fr33z3  | foo bar | foo | 

:しかし、キュウリは、シナリオを以下のために失敗した

... 
Then I should see "Signed in as <fullname>"                # features/step_definitions/web_steps.rb:108 

    Examples: 
     | email   | password | fullname | username | 
     | [email protected] | secretpass | man net | net  | 
     undefined method `fullname' for #<User:0x1057a62e0> (ActionView::Template::Error) 
     /Library/Ruby/Gems/1.8/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:364:in `method_missing' 
... 

は、モデル内

attr_accessor :username, :fullname 

のコメントを解除すると、キュウリの作業になりますが、私の見解では、私はすべてのフルネーム属性にアクセスすることはできません長い - 私は間違って何をしていますか?

UPDATE:キュウリはエラーを生成しませんが、フルネームがデータベースに挿入されていないため、テストは失敗します。

Started POST "/users" for 127.0.0.1 at Tue Feb 01 13:43:17 +0100 2011 
    Processing by Devise::RegistrationsController#create as HTML 
    Parameters: {"commit"=>"Sign up", "utf8"=>"✓", "user"=>{"password_confirmation"=>"[FILTERED]", "fullname"=>"foo bar", "username"=>"foo", "password"=>"[FILTERED]", "email"=>"[email protected]"}} 
    [1m[36mUser Load (0.3ms)[0m [1mSELECT "users"."id" FROM "users" WHERE (LOWER("users"."email") = LOWER('[email protected]')) LIMIT 1[0m 
    [1m[35mAREL (0.3ms)[0m INSERT INTO "users" ("current_sign_in_ip", "last_sign_in_ip", "created_at", "email", "remember_created_at", "reset_password_token", "password_salt", "last_sign_in_at", "remember_token", "sign_in_count", "current_sign_in_at", "encrypted_password", "updated_at") VALUES (NULL, NULL, '2011-02-01 12:43:18.265015', '[email protected]', NULL, NULL, '$2a$10$DzOCWVM1EHxp7E2asqfw8u', NULL, NULL, 0, NULL, '$2a$10$DzOCWVM1EHxp7E2asqfw8uNDPZifWxbBJA1xbfHh83nF1oOD9RTa6', '2011-02-01 12:43:18.265015') 
    [1m[36mAREL (0.1ms)[0m [1mUPDATE "users" SET "current_sign_in_ip" = '127.0.0.1', "last_sign_in_ip" = '127.0.0.1', "last_sign_in_at" = '2011-02-01 12:43:18.273337', "sign_in_count" = 1, "current_sign_in_at" = '2011-02-01 12:43:18.273337', "updated_at" = '2011-02-01 12:43:18.273724' WHERE ("users"."id" = 1)[0m 
Redirected to http://www.example.com/ 
Completed 302 Found in 325ms 

私はレール3.0.3と最新のキュウリ/カピバラ宝石

感謝を使いますあなたはどんな助けでも!

答えて

0

あなたはattr_accessibleリストにfullnameフィールドを定義しているが、物事のルックスで、何のフルネームフィールドは、あなたのusersテーブルに存在しない、また、あなたが持っている1がコメントのように、それは、任意のattr_accessorコールにリストされていますでる。

したがって、未定義のメソッド。

0

よろしくお願い致します。私は問題を発見したと思う:私はキュウリの機能を使用/私の移行では動作しませんでした。

レーキキュウリを使用すると問題なく動作します。そして、今もキュウリの機能/ ...作品!

関連する問題