RailsCasts Pro episodes are now free!

Learn more or hide this

Andrew Cockerham's Profile

GitHub User: andrewcockerham

Site: https://www.linkedin.com/in/andrewcockerham

Comments by Andrew Cockerham

Avatar

The coffeescript in the episode didnt work for me (I was trying to have the grouped_collection_select in a nested form, not sure if that was part of the issue)

But in any case, this did work, hopefully it helps someone: (using different id tags as the ones in my project)

Note the main difference being how I called the filter action

ruby
jQuery ->
        items = $('#quantity_item_select').html()
        $('.supplier_select').change ->
                supplier = $('.supplier_select :selected').text()
                options = $(items).filter((index) ->
                  $(this).attr("label") is supplier)
                if options
                        $('#quantity_item_select').html(options)
Avatar

I have the same issue. This SO question might help. However I haven't been able to get it to work myself.

Avatar

I'm having the same issue. For some reason it seems that my new.js.erb file is not getting loaded. My new action in my controller does not have a respond_to block, although the create action does.

Why is it not loading?

Avatar

I have the same question...does anyone know the answer?

Avatar

I have the exact same problem you did. I tried your Tubrolinks suggestion, but it doesn't work.

Where did you add the 'data-no-turbolink' tag?

UPDATE: I have it working now - I had my answer_fields wrapped in a tag rather than a tag

Thanks for your post though, turbolinks is very cool!

Avatar

I'm having the exact same problem. I tried Eric Wanchic's answers below regarding Turbolinks, but it didn't seem to help.

Since it's trying to execute the actual link to the '#' url, my guess is that for some reason the event.preventDefault() is not working because it is still trying to execute the link rather than running the javascript.

Anyone know how to fix it?

Avatar

Ok, so I downloaded the source code, and when a survey is updated, the params are this:

{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"yO16xiTDvjH1i4mvgUSK3XiDxiyzHM87PSGZAc57Cu4=",
"survey"=>{"name"=>"Rails Survey",
"questions_attributes"=>{"0"=>{"content"=>"kjhlkjh",
"_destroy"=>"0",
"answers_attributes"=>{"0"=>{"content"=>"kjlk",
"_destroy"=>"false",
"id"=>"2"}},
"id"=>"2"}}},
"commit"=>"Update Survey",
"id"=>"1"}

But I created a rails app from scratch following line by line in the railscast and I get an arror "Cannot convert Symbol into Integer" and my params are slightly different when updating a survey:

{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"I4IByp+jkutbWSHRM8z5zvLoKQ1AxfoyNhdMxJ02ORg=",
"survey"=>{"name"=>"Test 1",
"questions_attributes"=>{"content"=>""}},
"commit"=>"Update Survey",
"id"=>"1"}

So I have a feeling it has to do with the "0" that is before the "content" of "questions_attributes" in the source code params but not in my params. What am I doing wrong and how can I fix it?