Ruby on rails 在使用Desive的Rails应用程序中查看用户(索引、显示、编辑等)?
我正在使用Desive构建Rails应用程序。 即使是万能的,设计也都是现成的 控制器/用户\u controller.rb:Ruby on rails 在使用Desive的Rails应用程序中查看用户(索引、显示、编辑等)?,ruby-on-rails,Ruby On Rails,我正在使用Desive构建Rails应用程序。 即使是万能的,设计也都是现成的 控制器/用户\u controller.rb: class UsersController < ApplicationController def index @users = User.all end end class User < ActiveRecord::Base # Include default devise modules. Others available are:
class UsersController < ApplicationController
def index
@users = User.all
end
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :username
has_many :microposts
has_many :comments
def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
data = access_token.extra.raw_info
if user = User.where(:email => data.email).first
user
else # Create a user with a stub password.
User.create!(:email => data.email, :password => Devise.friendly_token[0,20])
end
end
end
<div>
<h2>Username: <%= user.username %></h2>
<p>Email: <%= user.email %></p>
<p>ID: <%= user.id %></p>
<br />
</div>
<h2>User index</h2>
<p>microposts <%= render @users %></p>
class UsersController
models/user.rb:
class UsersController < ApplicationController
def index
@users = User.all
end
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :username
has_many :microposts
has_many :comments
def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
data = access_token.extra.raw_info
if user = User.where(:email => data.email).first
user
else # Create a user with a stub password.
User.create!(:email => data.email, :password => Devise.friendly_token[0,20])
end
end
end
<div>
<h2>Username: <%= user.username %></h2>
<p>Email: <%= user.email %></p>
<p>ID: <%= user.id %></p>
<br />
</div>
<h2>User index</h2>
<p>microposts <%= render @users %></p>
class用户data.email)
用户
否则#创建具有存根密码的用户。
User.create!(:email=>data.email,:password=>design.friendly_令牌[0,20])
结束
结束
结束
views/\u user.html.erb:
class UsersController < ApplicationController
def index
@users = User.all
end
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :username
has_many :microposts
has_many :comments
def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
data = access_token.extra.raw_info
if user = User.where(:email => data.email).first
user
else # Create a user with a stub password.
User.create!(:email => data.email, :password => Devise.friendly_token[0,20])
end
end
end
<div>
<h2>Username: <%= user.username %></h2>
<p>Email: <%= user.email %></p>
<p>ID: <%= user.id %></p>
<br />
</div>
<h2>User index</h2>
<p>microposts <%= render @users %></p>
用户名:
电邮:
身份证:
views/index.html.erb:
class UsersController < ApplicationController
def index
@users = User.all
end
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :username
has_many :microposts
has_many :comments
def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
data = access_token.extra.raw_info
if user = User.where(:email => data.email).first
user
else # Create a user with a stub password.
User.create!(:email => data.email, :password => Devise.friendly_token[0,20])
end
end
end
<div>
<h2>Username: <%= user.username %></h2>
<p>Email: <%= user.email %></p>
<p>ID: <%= user.id %></p>
<br />
</div>
<h2>User index</h2>
<p>microposts <%= render @users %></p>
用户索引
微囊
但当我访问时,我得到:
没有与[GET]“/users”匹配的路由
我是否必须在视图/designe
文件夹中设置视图?在视图/设计/会话
文件夹或类似文件夹中?是否尝试添加
resources :users
到你的路线.rb?routes.rb有
resource:users
,对吗?一定要在调用design\u for:users
之后添加resources:users
,以确定设计路线的优先级。Ups,我认为design\u for
会干扰resources:users
。我想我错了。谢谢