Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6724679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:43:06+00:00 2026-05-26T09:43:06+00:00

Here is code in customers controller: def edit @customer = Customer.find(params[:id]) @return_to = params[:return_to]

  • 0

Here is code in customers controller:

  def edit
    @customer = Customer.find(params[:id])
    @return_to = params[:return_to]     
  end

  def update
    @customer = Customer.find(params[:id])

    if @customer.update_attributes(params[:customer], :as => :roles_new_update)

    redirect_to @return_to, :notice => 'Customer was updated successfaully!'
    else
      render 'edit', :notice => 'Customer was not updated!'
    end
  end

It is verified that there is value in @return_to in method edit. However there is an error saying: Cannot redirect to nil! for

   redirect_to @return_to, :notice => 'Customer was updated successfaully!'

in method update.

Any thoughts about the error? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:43:07+00:00Added an answer on May 26, 2026 at 9:43 am

    It’s because when you are on the edit action, that is one request to show the form. Then when you submit the form, that is a second request calling the update action. Any states set in an action are confined to that action alone. There’s a few ways to use data across multiple actions:

    1. The database (So save it in a model)
    2. The session hash
    3. Pass it in the view to go into your form.

    Because it’s a redirect/return to value, i would suggestion using a session variable such as:

    session[:return_to] = params[:return_to]
    

    In your edit action, then just refer to that value in your update:

    session[:return_to]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the code var customers = db.ExecuteQuery<Customer>(@SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City,
Here is the failed spec code for create in customer controller: describe CustomersController do
Here is the rspec code for testing show in customers controller: it 'show' should
Here is the snippet of code: <li> <g:link controller=Customer action=customerInfo id=${CustomerInstance.id} onclick=return confirm('${message(code: 'default.button.customerInfo.confirm.message',
Edit: The code here still has some bugs in it, and it could do
Quick question. Here is my code: #routes map.resources :customers, :has_many => [:addresses, :matchings] map.connect
Here is the error for update in rspec: 4) CustomersController GET customer page 'update'
I have this controller: def list = { withFormat { xml { render Customer.list()
So in my view controller, I run code to populate an NSArray of Customer
Here is the code: using (var context = new AventureWorksDataContext()) { IEnumerable<Customer> _customerQuery =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.