0
votes

Within coffescript code I have

app/assets/javascript/drill.js.coffee

...
$('document').ready ->
  if $('#x_eval_assum').length == 1
    $('#x_eval_assum')  
      .submit (event) ->
        event.preventDefault()
        data = $("#x_eval_assum").serialize()
        drill_id = $('.form.assumption').attr('data-drillid')
        $.post "/drills/#{drill_id}/discovery_target_saved.json", data, (res)->
           console.log(' here ')
      .change (event) ->
        event.preventDefault()
...

app/controller/drills_controller.rb

...
  def discovery_target_saved
    load_evaluation_assumption_selections
    load_user_positions
    render :json, {data: @drill.id}
  end

In Developer Tools Console I see this error POST .. host:3000/drills/13/discovery_target_saved.json 500 (Internal Server Error)

Have tried a number of variations - what am I doing wrong ?

More stuff

Both "load_evaluation_assumption_selections" and "load_user_positions" are Drill Controller actions that are working correctly and are used by other Drill actions.

I currently have another error showing on the internal log- specifically

Completed 500 Internal Server Error in 46ms

ActionView::MissingTemplate - Missing template drills/json, application/json with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in: * "/Users/davidlee/drill_investor/app/views" * "/Users/davidlee/.rvm/gems/ruby-2.1.1/gems/devise-3.4.0/app/views" : actionview (4.1.6) lib/action_view/path_set.rb:46:in find' actionview (4.1.6) lib/action_view/lookup_context.rb:124:infind

1
Is there some output, maybe this internal error, on the server console? What are you doing in load_evaluation_assumption_selections and load_user_positions. I guess we can't answer the question, because there is not enough information from your side. - Robin
is @drill getting set in the controller? If not then you'll get a no method error when you call .id on @drill - John
Also, I'm not sure your url will work. Try replacing your $.post line with this version: $.post "/drills/#{drill_id}/discovery_target_saved", data, (res)-> console.log('here'), "json" - John
Working shutting up eerly but will try as soonasIreturn tommorror- Pierre - user1854802

1 Answers

0
votes

Your app is looking for a view template named :json. Try this in the controller instead:

def discovery_target_saved
  load_evaluation_assumption_selections
  load_user_positions
  render json: {data: @drill.id}
end