# Same partial different results

**URL:** <https://www.ruby-forum.com/t/same-partial-different-results/183052>\
**Category:** Rails\
**Created:** [February 7, 2010, 3:27am UTC](https://www.ruby-forum.com/t/same-partial-different-results/183052 "2010-02-07T03:27:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [February 7, 2010, 3:27am UTC](https://www.ruby-forum.com/t/same-partial-different-results/183052/1 "2010-02-07T03:27:50Z")

</div>

Hey everyone.

I’m using a partial 3 times in my applications.html.erb file. When the  
index is loaded everything works exactly like it should. (the partial  
contains a collection\_select with prompts). If i goto the show action  
the options for the collection select seem to vanish. IE no prompt  
when rendered.

I’ve removed everything from the show.html.erb and def show action  
just incase there was some sort of run in. But there isn’t, it seems  
to just be a rendering problem.

Any ideas?

The partial:  
Select \<%= box %\>: \<%= collection\_select(“vehicle”, box, list, box,  
box,  
{:prompt =\> “Search by #{box}”, :selected =\>  
selected },  
{:onchange =\> "#{remote\_function(:url =\> {:action  
=\> “update\_dropdowns”},  
:with =\>  
"‘current\_id=’+id+

‘&current\_value=’+value+

‘&fields=’+

‘year=’+$(vehicle\_year).value+’,’+

‘make=’+$(vehicle\_make).value+’,’+

‘model=’+$(vehicle\_model).value")}"}) %\>

---

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [February 8, 2010, 12:20am UTC](https://www.ruby-forum.com/t/same-partial-different-results/183052/2 "2010-02-08T00:20:43Z")

</div>

So it turns out it’s not just the partial. Any dropdown select i ad to  
that page will not properly display :prompt. Now I have an ajax update  
method so If i change the select all selects are reloaded. And as soon  
as I change one they all act accordingly with prompt displayed  
properly.

So it seems only the inital page load is messing up the rendering.

Anyone have any ideas?

Even a method to force reload that container on load so it would  
properly adjust would be decent.

---

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [February 8, 2010, 10:45am UTC](https://www.ruby-forum.com/t/same-partial-different-results/183052/3 "2010-02-08T10:45:16Z")

</div>

On 7 February 2010 23:19, brianp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So it turns out it’s not just the partial. Any dropdown select i ad to  
> that page will not properly display :prompt. Now I have an ajax update  
> method so If i change the select all selects are reloaded. And as soon  
> as I change one they all act accordingly with prompt displayed  
> properly.
> 
> So it seems only the inital page load is messing up the rendering.

Two suggestions, firstly have a look at the html of the page (View,  
Page Source, or similar, in browser) and see if the prompt is there.  
If it is then copy and paste the code into the w3c html validator at  
[The W3C Markup Validation Service](http://validator.w3.org/#validate_by_input) and see if there are any  
errors.

Colin

---

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [February 9, 2010, 9:09am UTC](https://www.ruby-forum.com/t/same-partial-different-results/183052/4 "2010-02-09T09:09:51Z")

</div>

Hey Colin,  
thanks for the reply.

I did think to check for that and un-fortunately the html for the  
prompt (first ) is not generated at all. It immediately skips  
to the first object in the list, just as if the prompt wasn’t there at  
all.

---

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [February 9, 2010, 9:39am UTC](https://www.ruby-forum.com/t/same-partial-different-results/183052/5 "2010-02-09T09:39:07Z")

</div>

Just found my problem.

\<%= collection\_select(:Vehicle, box, list, box, box,

I previously had :vehicle. Which I’m assuming wasn’t actually being  
recognized as Model type due to case. Weird that it still functioned  
on the index but broke on the show.

Either way it works now. Weird little glitch I guess. I could  
understand if it didn’t work at all lol.

Thanks for the suggestion Colin!
