0
我剛安裝了設計,但他們給我的默認路線&都是搞砸了。我嘗試訪問視圖時遇到了很多錯誤。我使用3.2.13 &最新色器件(1.1.rc0)設計:路線搞砸了
這裏有一些錯誤,我有以下生成的用戶模型獲取(使用rails generate devise User
)軌道
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :lockable, :timeoutable and :activatable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation
# attr_accessible :title, :body
end
運行的遷移之後,這是在我的路線添加的文件
devise_for :users
當我嘗試訪問該頁面sign_up我得到這個錯誤
undefined method `user_registration_path' for #<#<Class:0x007f8079d87c68>:0x007f8079badc30>
這裏是圖,其中錯誤發生
<h2>Sign up</h2>
<%= form_for(resource_name, resource, :url => registration_path(resource_name)) do |f| %>
<%= f.error_messages %>
<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>
<p><%= f.label :password %></p>
<p><%= f.password_field :password %></p>
<p><%= f.label :password_confirmation %></p>
<p><%= f.password_field :password_confirmation %></p>
<p><%= f.submit "Sign up" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>
很明顯的,爲什麼失敗,因爲這裏是我耙路線返回
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session GET /users/sign_out(.:format) devise/sessions#destroy
password POST /users/password(.:format) devise/passwords#create {:name_prefix=>:user}
new_password GET /users/password/new(.:format) devise/passwords#new {:name_prefix=>:user}
edit_password GET /users/password/edit(.:format) devise/passwords#edit {:name_prefix=>:user}
PUT /users/password(.:format) devise/passwords#update {:name_prefix=>:user}
POST /users/registration(.:format) devise/registrations#create {:name_prefix=>"user_registration"}
new GET /users/registration/sign_up(.:format) devise/registrations#new {:name_prefix=>"user_registration"}
edit GET /users/registration/edit(.:format) devise/registrations#edit {:name_prefix=>"user_registration"}
PUT /users/registration(.:format) devise/registrations#update {:name_prefix=>"user_registration"}
DELETE /users/registration(.:format) devise/registrations#destroy {:name_prefix=>"user_registration"}
confirmation POST /users/confirmation(.:format) devise/confirmations#create {:name_prefix=>:user}
new_confirmation GET /users/confirmation/new(.:format) devise/confirmations#new {:name_prefix=>:user}
GET /users/confirmation(.:format) devise/confirmations#show {:name_prefix=>:user}
顯然正確的路線是new_path
。
這裏是另一個錯誤我正在試圖訪問sign_in視圖
wrong number of arguments (3 for 2)
查看
<h2>Sign in</h2>
<%= form_for(resource_name, resource, :url => session_path(resource_name)) do |f| %>
<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>
<p><%= f.label :password %></p>
<p><%= f.password_field :password %></p>
<% if devise_mapping.rememberable? -%>
<p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
<% end -%>
<p><%= f.submit "Sign in" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>
我以前也使用過色器件,但我不記得讓所有這些錯誤的。到底是怎麼回事?我並不認爲它是開箱即用的。
你能分享你如何在routes.rb文件中定義路線嗎? –
當然,Ill現在編輯該編輯 – user2158382
您安裝了哪個版本的編輯器?你說最新的,然後提到'1.1.rc0'。最新版本的設計是'3.2.4' –