Solved

how to make select element 'remember' previous value

Posted on 2011-09-19
2
378 Views
Last Modified: 2012-05-12
so in a rails app i have this collection_select element as part of a form. When creating a story object it works fine but on subsequent edits the select element never remembers the previous value, users rarely change the edition during an edit but ofter forget to check it. So how to i make it remember its value when editing?



<%= collection_select(:story, :edition_id, Edition.all, :id, :name, {:include_blank => '-select story type-'} ) %>
0
Comment
Question by:depassion
2 Comments
 
LVL 10

Accepted Solution

by:
Andrew Doades earned 500 total points
ID: 36563766
Is the edition_id being stored in the database correctly?
I have a similar collection select that works OK:

<%= collection_select 'sub_category', 'parent_id', @categories, :id, :description, {:include_blank => true} %>
0
 

Author Comment

by:depassion
ID: 36565127
oh yeah, i was storing edition_id as a string, which should of course be an integer. Works now, thanks.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question