rails api doc

   select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] 
}, {:prompt => 'Select Person'})


tom

bingo bob wrote:
> 
> Been trying all morning - daft thing ARRRRRGH!
> 
> I'd like to have the top option in my drop down to be "please select"
> and if that's the case All teachers should be shown.
> 
> I can't get the Please Select to work though ?
> 
> 
> 
> ---------
> 
> view
> ===
> 
> 
> <% title "Welcome" %>
> 
> 
> <p>Find me in app/views/welcome/index.html.erb</p>
> 
> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
> eiusmod tempor incididunt ut
>    labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
> exercitation ullamco
>   laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
> in reprehenderit in
>    voluptate velit esse cillum dolore eu fugiat nulla pariatur.
> Excepteur sint occaecat
>   cupidatat non proident, sunt in culpa qui officia deserunt mollit anim
> id est laborum.
> </p>
> 
> <hr>
> 
> 
> <% form_tag do %>
>   Filter on location:
>   <%= select_tag "location_id",
> options_from_collection_for_select(@all_locations, :id, :name, selected
> = @location.id), :prompt => "Please Select" %>
> 
> 
>   <%= submit_tag "Go" %>
> <% end -%>
> 
> <hr>
> 
> <% if @teachers %>
>   <% for teacher in @teachers %>
>     <%= link_to [teacher.first_name + ' ' + teacher.last_name], teacher
> %><br>
>     <%= teacher.email %><br>
>     Location: <%= teacher.location.name %>
> 
> 
>     <hr>
>   <% end %>
> 
> <% end %>
> 
> 
> 
> controller
> ======
> 
> class WelcomeController < ApplicationController
>   def index
> 
>     @all_locations = Location.all
>     @location = Location.find(params[:location_id].to_i) if
> params[:location_id]
> 
>     if @location
>       @teachers = @location.teachers
>     else
>       @teachers = Teacher.all
>     end
> 
>   end
> end


-- 
===============================================================================
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===============================================================================

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to