VRFS-278 musician_instruments are now populated on signup failure
This commit is contained in:
parent
1b43341cca
commit
7d62c292cb
|
|
@ -77,6 +77,7 @@ class UsersController < ApplicationController
|
|||
# render any @user.errors on error
|
||||
load_location(request.remote_ip, location)
|
||||
gon.signup_errors = true
|
||||
gon.musician_instruments = instruments
|
||||
render 'new'
|
||||
else
|
||||
if @user.email_confirmed
|
||||
|
|
@ -186,7 +187,6 @@ class UsersController < ApplicationController
|
|||
# also, make up priority because we don't ask for it (but users can fix it later on their profile)
|
||||
priority = 0
|
||||
original_instruments.each do |key, value|
|
||||
logger.debug("key #{key} value:#{value}")
|
||||
if !value["selected"].nil?
|
||||
instruments << { :instrument_id => key, :proficiency_level => value["proficiency"].to_i, :priority => priority }
|
||||
priority = priority + 1
|
||||
|
|
|
|||
|
|
@ -125,8 +125,8 @@
|
|||
<table id="instrument_selector" class="instrument_selector" width="100%" cellpadding="0" cellspacing="6">
|
||||
<% Instrument.standard_list.each do |instrument| %>
|
||||
<tr>
|
||||
<td><input id="<%= instrument.id %>_checkbox" name="jam_ruby_user[instruments][<%= instrument.id %>][selected]" type="checkbox" /><%= instrument.description %></td>
|
||||
<td align="right" width="50%"><select name="jam_ruby_user[instruments][<%= instrument.id %>][proficiency]" class='proficiency_selector'><option value="1">Beginner</option><option value="2">Intermediate</option><option value="3">Expert</option></select></td>
|
||||
<td><input id="<%= instrument.id.gsub(" ", "") %>_checkbox" name="jam_ruby_user[instruments][<%= instrument.id %>][selected]" type="checkbox" /><%= instrument.description %></td>
|
||||
<td align="right" width="50%"><select id="<%= instrument.id.gsub(" ", "") %>_proficiency" name="jam_ruby_user[instruments][<%= instrument.id %>][proficiency]" class='proficiency_selector'><option value="1">Beginner</option><option value="2">Intermediate</option><option value="3">Expert</option></select></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
|
@ -173,6 +173,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
// populate musician instruments from previous submit, if applicable
|
||||
if(window.gon && gon.musician_instruments) {
|
||||
$(gon.musician_instruments).each(function(index, value) {
|
||||
$('#' + value.instrument_id.replace(" ", "") + "_checkbox").attr("checked", true);
|
||||
$('#' + value.instrument_id.replace(" ", "") + "_proficiency").val(value.proficiency_level.toString())
|
||||
})
|
||||
}
|
||||
|
||||
// show signup errors, if any
|
||||
if(window.gon && gon.signup_errors) {
|
||||
var errors = <%= @user.errors.to_json.html_safe %>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue