Ruby on rails 一个控制器/某物/某物中的多个功能
当前添加控制器时,它具有ex./dashboard/index 如何实现/dashboard/editaccount ex?如何“呈现”此(视图)的模板Ruby on rails 一个控制器/某物/某物中的多个功能,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,当前添加控制器时,它具有ex./dashboard/index 如何实现/dashboard/editaccount ex?如何“呈现”此(视图)的模板 class仪表板控制器
class仪表板控制器
我是RubyonRails的新手,希望你们能回答我这个初学者的问题。类仪表板控制器class DashboardsController < ApplicationController
def index
user = Users.find(session[:id])
@username = user[:username]
end
def edit_account
# Your code
# automatically renders the 'edit_account' template
end
end
# config/routes.rb
resource :dashboard do
get 'edit_account', on: :collection
end
def索引
user=Users.find(会话[:id])
@用户名=用户[:用户名]
结束
def编辑账户
#你的代码
#自动呈现“编辑帐户”模板
结束
结束
#config/routes.rb
资源:dashboard do
在::集合上获取“编辑帐户”
结束
了解更多关于
请注意,我已将仪表板控制器的命名更改为仪表板控制器
。即使在使用单数路由时,通常也会以复数形式命名控制器(请参阅上面的Rails指南链接并搜索单数资源)
class DashboardsController < ApplicationController
def index
user = Users.find(session[:id])
@username = user[:username]
end
def edit_account
# Your code
# automatically renders the 'edit_account' template
end
end
# config/routes.rb
resource :dashboard do
get 'edit_account', on: :collection
end