Tag: 重定向

URL重定向和1and1

我已经在Heroku上运行了一个应用程序。 我从1and1购买了一个顶级.com域名(我在那里有其他网站,所以我认为这会让生活更轻松)。 当我尝试重定向到我的Heroku应用程序时,我不允许修改CName别名记录,就像我为其他站点所做的那样 – 这些都是子域名。 我有两个选择:帧重定向或HTTP重定向,我试过两个。 帧重定向似乎根本不起作用 – 页面保持空白。 HTTP重定向确实会到达我的heroku站点,但是当它显示时,地址栏显示myproject.herokuapp.com而不是mydomain.com 。 我已将www.mydomain.com和mydomain.com添加到我的heroku域名中。 无论如何要添加面具或类似物?

如何重定向到routes.rb中的404页面?

如何将不正确的URL重定向到routes.rb中的404页面? 现在我使用2个示例代码: # example 1 match “/go/(*url)”, to: redirect { |params, request| Addressable::URI.heuristic_parse(params[:url]).to_s }, as: :redirect, format: false # example 2 match “/go/(*url)”, to: redirect { |params, request| Addressable::URI.heuristic_parse(URI.encode(params[:url])).to_s }, as: :redirect, format: false 但是当我尝试在’url’参数中使用俄语单词时,在第一个例子中我得到500页(坏URI),在第二个 – 我得到重定向到stage.example.xn – org-yedaa​​a1fbbb / 谢谢

当操作依赖于传递的参数时,如何使用redirect_to?

当Edit操作依赖于传递的参数时,如何使用redirect_to? 我有两个非常简单的动作编辑和更新。 点击提交后,在更新后我想将用户重定向回编辑操作。 如果编辑操作需要参数,我该怎么做? def edit @account = Account.find_by_user_id(@params[‘user_id’]) end def update account = Account.find(params[:account_user_id]) if account.update_attributes(params[:name]) redirect_to params[:user_id].merge!(:action => :edit) else render :text => ‘Sorry there was an error updating.’ end end 这段代码爆炸了

Sinatra 1.3 Streaming w / Ruby stdout重定向

我想使用1.3中引入的Sinatra的Streamingfunction以及一些stdout重定向。 它基本上是一个长期工作的实时流输出。 我在自述文件中查看了这个问题和Sinatra流式传输示例。 在OSX上运行1.8.7: require ‘stringio’ require ‘sinatra’ $stdout.sync = true module Kernel def capture_stdout out = StringIO.new $stdout = out yield out ensure $stdout = STDOUT end end get ‘/’ do stream do |out| out << "Part one of a three part series… \n” sleep 1 out << "…part two… \n” sleep 1 out […]

rails – 重定向回,除非上一页是艺术家页面

我想重定向回到上一页,除非前一页是我的’艺术家’控制器”show’动作。 所以我猜它会是这样的: if *previous page was artist show* redirect_to [track.artist, track] else redirect_to :back end 我的问题是 – 我如何测试前一页是否是我的艺术家控制器的节目动作..?

如何将before_filter应用于Rails 3.2.11中每个控制器的每个动作?

我想validation用户是否登录到服务器的每个请求。 就像是: :before_filter verify_logged_in 我应该在哪里放置before_filter,以便它适用于所有控制器操作和所有请求?

Heroku 301重定向

我怎么做到这一点http://domain.com 301重定向到http://www.domain.com ? 我习惯使用.htaccess来ModRewrite它,但我知道我不能在Heroku上做到这一点。 .htaccess的示例: Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.com [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] 我的文件结构: – /public — /style — index.html – config.ru 我只是提供单页,我的config.ru包括: use Rack::Static, :urls => [“/style”], :root => “public” run lambda { |env| [ 200, { ‘Content-Type’ => ‘text/html’, ‘Cache-Control’ => ‘public, max-age=86400’ }, File.open(‘public/index.html’, File::RDONLY) ] }

Rails将无效路由重定向到root

如果我的网站是www.foo.com如果用户输入www.foo.com/blahblahblah它会说/blahblahblah是一条无效的路径(显然)。 但我希望它改为重定向到root_path,以便控制器可以处理URL – 应该呈现页面www.foo.com我想拉文本blahblahblah并用它做一些事情。 我该怎么做呢?

将param值传递给redirect_to作为rails中的查询字符串

这应该很简单,但我似乎找不到简单的答案。 如何将当前请求中的参数值传递给redirect_to调用? 我有一些表单值,我想传递给GET重定向的查询字符串 我想做的事情如下: redirect_to @thing, :foo => params[:foo] 并被发送到: http://things/4?[foo][key1]=val1&[foo][key2]=val2 谢谢! 另外 – 如何处理redirect_to:back? redirect_to :back, :foo => params[:foo]

respond_with redirect with notice flash message not working

我正在使用rails 3.0.7。 在控制器中我有: def create @subscription = Subscription\ .new_from_nested_attributes_parameters(params[:subscription]) if @subscription.save flash[:notice] = ‘The Subscription was successfully created.’ end respond_with @subscription end 并在视图中: 尽管正确保存了对象,但不打印任何内容。 你对我该如何解决这个问题有所了解吗?