Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 一个控制器/某物/某物中的多个功能_Ruby On Rails_Ruby_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 一个控制器/某物/某物中的多个功能

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仪表板控制器

当前添加控制器时,它具有ex./dashboard/index 如何实现/dashboard/editaccount ex?如何“呈现”此(视图)的模板

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