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

  • SEARCH
  • Home
  • 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 7428507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:48:44+00:00 2026-05-29T08:48:44+00:00

So the flow of the problem is as follow, someone has an object, that

  • 0

So the flow of the problem is as follow, someone has an object, that has a title. The user can edit this object’s name in its edit controller with a form. The name is required to not be empty, so if the user tries to save the object with its name empty, it throws a validation error.

if @object.update_attributes(params[:object])
  flash[:notice] = "Successfully updated object"
  redirect_to @object
else
  render :action => "edit"
end

This validation error causes render :action => "edit" to be called. The problem arises here as on the edit view, both a series of breadcrumbs and a title are attempted to be filled, but as @object.update_attributes(params[:object]) has already been called, the object, while not being saved to the database, has now got its title = “”. This makes the breadcrumb look like “Objects >> >> Edit” instead of “Objects >> AwesomeObject >> Edit”

So my question is can i retain the last previous saved name, the one that will still be in the database to use as a placeholder instead of “” while the user fixes the blank field?

  • 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-29T08:48:44+00:00Added an answer on May 29, 2026 at 8:48 am

    It is possible to add a method that retrieves the name again from the database, for example like this:

    def breadcrumb_title
      persisted? ? Object.find_by_id(id).title : self.title
    end
    

    Object is the name of the model and the call to persisted just makes sure that the instance exists in the database. However, this might generate unnecessary database calls. Another option could be to use the built-in changes hash to see what the previous value was. The changes hash works like this:

    ?> a = Object.new
    => #<Object id: nil, title: nil>
    ?> a.changes
    => {}
    ?> a.title = "first title"
    => "first title"
    ?> a.changes
    => {"title"=>[nil, "first title"]}
    ?> a = Object.first
    => #<Object id: 1, title: "Original title">
    ?> a.changes
    => {} 
    ?> a.title = "title changed"
    => "title changed"
    ?> a.changes
    => {"title"=>["Original title", "title changed"]}
    

    So you should be able to retrieve the previous title with a method like this:

    def breadcrumb_title
      self.errors["title"].present? ? self.changes["title"].first : self.title
    end
    

    This will check if there is any error with the title and if it is then take the previous value of the title. But if there are no errors then it will default to the current value of title.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My program flow is like this: I need to sequential processing per user's request
The problem is a footer on a web page that seem to not follow
i have a flow that works as follows: <flow name=ChatListener> <quartz:inbound-endpoint jobName=eventTimer repeatInterval=${chatListener.pollingInterval}> <quartz:event-generator-job
I have a problem with the FO flow, because on one page the title
I want to create a natural flow of content. The problem that I now
I have a very complicated problem that occurs only for non-admin windows user. I
I have an embedded XMLHttpRequest problem; The flow of data should go like this:
Does this problem have a name? Given a directed and strongly connected graph with
Flow player claims that it supports all file formats. Do the video files need
I have the following flow: A user is presented with a form. He fills

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.