滑轨,相同视图,不同控制器 [英] Rails, same view, different controllers

查看:78
本文介绍了滑轨,相同视图,不同控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

map.resources:persons

map.resources :persons

map.resources:people

map.resources :people

class Persons_controller < ApplicationController::Base
  #the whole logic for the controller
end

class People_controller < PersonsController
  #nothing special there
end

我如何使用/ app / views / persons /当我从 http://mydomain.com/people/1 访问应用时a>?

How I can use the views from /app/views/persons/ when I access my app from http://mydomain.com/people/1 ?

我收到关于缺少人员/show.erb视图的错误,我不想使用任何符号链接

I get an error about missing people/show.erb view , I don't want use any symlinks

推荐答案

我认为正确的做法是遵循David Lyod的建议。更好的组织方式,您始终知道共享文件的位置。但是,您仍然可以通过将_people.html.erb部分放置在views / persons目录中来使用相同的概念。然后在使用它的人员查看文件中

I think the right thing to do is follow David Lyod's advice. It's much better organization and you always know where your shared files are. However, you can still use the same concept by placing the partial _people.html.erb in the views/persons directory. Then in the people view file that uses it

render :partial => "persons/people"

希望这会有所帮助。

这篇关于滑轨,相同视图,不同控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆