Displaying 20 results from an estimated 50000 matches similar to: "redirect_to with hash vs string and docs"
2006 Jul 03
0
REST vs. render vs. redirect_to w.r.t. create error messages, efficiency and the desired URL
Hi,
Something has been bothering me for a long time and I''d like to know
what other think about this common situation with Rails.
Someone is looking at http://example.com/user/new where there is a
form that POSTs the data to the user/create action. The controller
might look like
def new
@user = User.new
end
def create
@user = User.new(params[:entry])
if @user.save
2007 Apr 02
2
redirect_to an uncertain hash
I am trying to deal with a redirection based upon what to do after a
session has expired. I take the params hash and stuff it into a new
session as part of the new login and then after login, I want to
redirect to this hash as though they were params again...
Thus I start by setting
session[:direct_to] = @params
And after I login, I want to redirect based upon the values in
2012 Jan 19
4
redirect_to with a hash instead of parameters
All,
I have numerous places in my codebase like this:
redirect_to :action => ''schedule_by_uid_and_run_date'', :uid =>
@schedule.first.train_uid, :year => @date.year, :month => @date.month,
:day => @date.day
I''d like to replace the :year, :month and :day parameters with a hash
containing the three parameters. @date is an instance of a Date class,
2007 May 03
3
0.9.2 redirect_to no longer accepts hash?
Why am I now getting these errors?
expected redirect to {:action=>"index"}, got redirect to
"http://test.host/authenticated_users"
I know in the AuthenticatedUsersController, the redirect call is
redirect_to :action => ''index''
So why should I have to convert this to a url in my specs?
2006 Feb 13
1
Change redirect after method ''redirect_to''
I want to be able to change the redirection url after I called
redirect_to, is that possible?
My specific use case is that I want to change the default redirection of
"Login Engine" method signup, but I am seeing no other way then
copy/past and change the parameters of redirect_to.
This questions extends to render method as well, I want is to avoid
DoubleRenderError exception.
--
2009 Jan 28
4
format.html and redirect_to
I was wondering what the purpose of wrapping a redirect_to in a
format.html block is. I get why you''d want to do this with a render,
but if you''re redirecting the browser to another URL, what''s the
point? As I understand it, when redirect_to is called, Rails sends a
302 back to the browser, so I''m having trouble understanding why
format plays any part in this.
2013 Jan 18
1
redirect_to(session[:return_to]) vs session.delete
Hey all,
Recently I''ve been looking into on how to return back to a previous
referring URL and and the most common approach is:
redirect_to session[:return_to]
But some recommend:
redirect_to(session.delete(:return_to) || default)
How I understand it, in the second example we call session.delete so it
will clear the return path since we will no longer need it, and we also use
2007 Feb 15
0
Error handleing with redirect_to
I''m sketching out a error handler, something like
if cando = false
redirect_to( :controller => Oops,
:action => ''accessdenied'',
:type => ''alarm'',
:message => ''no_permission_to_view'',
:return_to => saved_url,
)
else
....
end
Is this an
2006 May 25
0
Test redirect_to fails
Hi
I have a weird issue on functional testing
Here is the redirect I have in my controller:
redirect_to :controller => "/param/user", :action => :edit, :id
=> @current_user.id
And here is my functional test:
assert_redirected_to :controller => "/param/user", :action
=> :edit, :id => users(:vincent).id
And when I run test I have this error
2006 May 31
5
Sharing code between some controllers? Staying DRY
Hi,
I have four controllers: one for the store front and three for the
store admin. In each controller I have copied and pasted exactly the
same code. It is a method called redirect_to() to override Action
Controller''s redirect_to(). Copy and paste is bad. I can think of two
options but I don''t know how Rails will feel about them.
Option 1: Can I create an intermediate
2006 Feb 02
1
redirect_to response code?
hi,
I wanted to make some redirects from my old page urls to my new ones.
In order to make google see the pages have moved permanently, I have
to send a 301 moved permanently code to google. when I use redirect_to
it sends a 302 moved temp. code. Can I change this behaviour?
Thanks in advance.
2006 Jul 22
2
redirect_to error
Hi,
I have a redirect_to statement in a method that I would like to have
at the end of the method to take you to a ''Success'' page if
everything works.
When I hit the redirect_to statement, ( redirect_to :action =>
''show_success'' )
I get this in the browser:
Application error
Rails application failed to start properly"
The development.log
2006 Mar 24
6
login forms , redirect_to and ajax-scaffold problems
Hi,
I have a standard type authentication technique direct from AWDWR, so there is a
before_filter :authorize_employee, :except => :login in my employees_controller.rb
the authorize_employee is in application.rb
def authorize_employee
unless session[:employee_id]
flash[:notice] = "Please log in"
# save the URL the user requested so we can hop
2006 Jul 15
1
Redirect_to from initialize method
Hello, I''m curious as to why this bit of code doesn''t work:
--
class SignupController < ApplicationController
def initialize
signup.call
end
def signup
redirect_to :action => "signup_form"
end
end
--
You have a nil object when you didn''t expect it!
The error occured while evaluating nil.rewrite
--
Whereas if I comment the
2007 Jul 26
6
response.should_not redirect_to
Hey,
May be it is just too deep night over here and I''m missing something
though I got this failure on {{{response.should_not redirect_to}}}:
''QueuesController should allow authenticated user to access ''show''''
FAILED
Matcher does not support should_not.
See Spec::Matchers for more information
about matchers.
Also I''ve found this in
2006 Mar 12
0
redirect_to with different HTTP error status
Hi all,
when using redirect_to rails redirects and automatically sets the HTTP
status to 301. Is there a way to change this? I''d like to redirect
with the HTTP status 302 (moved permanently).
Any help would be greatly appreciated!
Thanks,
Daniel
--
Posted via http://www.ruby-forum.com/.
2006 Mar 30
4
redirect_to("url") with post?
Is there a Rails-friendly way to redirect_to an url and post some
parameters with that?
I''ve tried:
redirect_to("http://whatever.com", { ''postme'' => ''this'' })
redirect_to("http://whatever.com", :post => { ''postme'' => ''this'' })
redirect_to("http://whatever.com", :options
2006 Mar 13
1
issue with redirect_to
Hi all:
I can''t make redirect_to to unlock the current iframe using {:TARGET =>
"_top"}. It always stays in the current frame. I checked the
redirect_to code, it seems the method does not use "target". here is the
source code of redirect_to from ActionController::Base
def redirect_to(options = {}, *parameters_for_method_reference) #:doc:
753: case options
2008 Feb 28
2
redirect_to or render
Hey, a newbie here.
Can someone please give me a brief explanation whats the difference
between the redirect_to method and the render method and when should I
use one instead of the other ?
thnx alot !
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send
2007 Aug 15
4
nuby: how spec redirect_to at ApplicationController
Good morning rspec people!
Still rspec nuby: I must do something wrong obviously.
How can I spec about redirect_to at ApplicationController
describe ApplicationController do
it "method login_required should redirect to home path without login" do
pending "I tried to use controller.login_required.should be_redirected
and got NoMethodError with nil object