0
我想在选中时显示选定人员的电子邮件。这是我到目前为止有:根据选定的Ruby on Rails显示新值
html.erb
<%= select_tag "", options_from_collection_for_select(Person.all, :id, :name), :id =>"test" %>
js.coffee
jQuery ->
$('select#test').change ->
$.get '/update_email/',{ id: $('option:selected', this). val() }
控制器
def update_email
@selected_person = Person.find(params[:id])
@email = @selected_person.email
end
我怎样才能显示@email?