我是Ruby on Rails的新手.我已阅读本教程,听起来非常简单.
但是我如何连接到我的数据库(MySQL)或Rails使用什么?在php我会用...
mysql_connect("...","...","...");
mysql_select_db("...");
Run Code Online (Sandbox Code Playgroud)
我搜索了谷歌,找不到任何有用的提示.
我即将建立一个自动放置&pni=somethingURL的系统.如果网址只是http://t.co/something.php并带有"?pni = ...." 就很容易了,但用户也可以http://t.co/something.php?myown=paramater然后系统应该添加&而不是?
如何将pni参数放在URL后面并且每次都有效?我没试过就试过这个.
<?php
function nice($in){
$out = parse_url($in);
return $out['scheme'] . "://" . $out['host'] . $out['path'] . "?" . $out['query'];
}
$urls = array(
"http://t.co/something.php?w=23&",
"http://t.co/something.php?w=23&dfdf=",
"http://t.co/something.php?",
"http://t.co/something.php",
"http://t.co/something",
"http://t.co/something.php?w=23&dfdf=34&hvem",
);
foreach ( $urls as $url):
echo print_r(nice($url)) . "<br/>";
endforeach;
?>
Run Code Online (Sandbox Code Playgroud) 你好,我对ruby on rails是全新的.
我收到此错误:未定义的局部变量或方法`hej'
在我的application.html.erb我有:
<%=hej%>
Run Code Online (Sandbox Code Playgroud)
并在application.controller我有这个:
class ApplicationController < ActionController::Base
def index
hej = "Hej hans" #also tried @hej = "Hej hans"
end
end
Run Code Online (Sandbox Code Playgroud)
__URL /家/索引