ruby中怎么建立url,实现页面的跳转,简单实现就好。代码要具体。

Python014

ruby中怎么建立url,实现页面的跳转,简单实现就好。代码要具体。,第1张

是Ruby, 还是Rails?

如果是在 Rails 里,直接在Action中写,比如:

def hello

redirect_to :action =>"index"

end

def hello

redirect_to 'http://baidu.com'

end

在这个页面的action中写

<% if @url %>

<script text/javascript>

window.open(<%=@url %>)

</script>

<% else %>

<script text/javascript>

alert("你没有给@url赋值!")

</script>

<% end %>