Ruby on rails ruby如果登录使用。loggedin.rhtml否则使用notloggedin.rhtml

Ruby on rails ruby如果登录使用。loggedin.rhtml否则使用notloggedin.rhtml,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,我必须使用ruby而不是php,如果登录,需要告诉ruby使用loggedin.rhtml,如果不使用notloggedin.rhtml。但是这些文件只包含页面菜单的一部分,因此它类似于php include函数,但带有if语句,Ruby可以执行shell脚本,php也不例外 if logged_in? output = `this.php` else output = `that.php` end 这将执行This.php或that.php,并将脚本输出存储在output中,前提是脚

我必须使用ruby而不是php,如果登录,需要告诉ruby使用loggedin.rhtml,如果不使用notloggedin.rhtml。但是这些文件只包含页面菜单的一部分,因此它类似于php include函数,但带有if语句,Ruby可以执行shell脚本,php也不例外

if logged_in?
  output = `this.php`
else
  output = `that.php`
end
这将执行
This.php
that.php
,并将脚本输出存储在
output
中,前提是脚本具有适当的:

#/usr/bin/env-php

请注意,这类似于,脚本不能访问Rails环境中的任何对象,即不能使用或之类的变量。如果脚本中需要任何数据,必须将其作为参数显式传递。

无论登录问题如何,Ruby如何“使用PHP”开始?为什么要混合使用这两个呢?我想是的,如果我通过ruby调用它,然后继续使用ruby和drop php,那么可以用ruby编写这个命令吗?如果登录,是否可以用ruby编写A,或者用ruby编写B?我当然希望如此。好吧,让我们坚持ruby。。。我在左边有一个页面和一个基本菜单div,我把它放在了一个新的notlogged.rhtml中。并为用户登录时创建了第二个菜单loggedin.rhtml。因此,如果登录或未登录,页面将加载相关内容(模板页面)
#!/usr/bin/env php
<?php
   echo "hello world";
?>