When I keep multiple choices from the ruby โโshape on the rails, it seems to add an empty element in front. How to remove it? Field selected_player.
{"utf8"=>"โ", "authenticity_token"=>"H8W7qPBezubyeU0adnTGZ4oJqYErin1QNz5oK0QV6WY=", "schedule"=>{"event"=>"1", "result_id"=>"", "time"=>"26/10/2012", "duration"=>"15", "arrival_time"=>"14", "location_id"=>"25", "selected_players"=>["", "38", "41"], "team_id"=>"1", "opponent_id"=>"7", "home_or_away"=>"Home"}, "commit"=>"Save Event"}
controller
def update @schedule = Schedule.find(params[:id]) @user = User.find(current_user) @players = User.where(:team_id => current_user[:team_id]).all respond_to do |format| if @schedule.update_attributes(params[:schedule]) Notifier.event_added(@user,@schedule).deliver format.html { redirect_to(@schedule, :notice => "#{event_display_c(@schedule.event)} vs #{@schedule.opponent.name} was successfully updated.") } format.json { head :no_content } else format.html { render :action => "edit" } format.json { render :json => @schedule.errors, :status => :unprocessable_entity } end end end
Paul 'Whippet' McGuane
source share