RailsCasts Pro episodes are now free!

Learn more or hide this

Pranay's Profile

GitHub User: ipranay

Comments by Pranay

Avatar

Did you find a solution to this?.. I am getting a similar error!

Avatar

Well, you could add :dependent => :destroy to each has_many association. and then simply delete your Survey!

Avatar

I encountered this too!.. any solutions so far?

Avatar

Sweet.. I was looking for this... Thanks!

Avatar

Thanks for this ryan, amazing as always!
I used this with Kaminari along with using a script to see if the pagination links are in the window view area (since I was working with a table that is in the middle of the page)
Coffee Script below:

javascript
jQuery ->
        isScrolledIntoView = (elem) ->
                docViewTop = $(window).scrollTop()
                docViewBottom = docViewTop + $(window).height()
                elemTop = $(elem).offset().top
                elemBottom = elemTop + $(elem).height()
                (elemTop >= docViewTop) && (elemTop <= docViewBottom)

        if $('.pagination').length
                $(window).scroll ->
                        url = $('.pagination .next_page a').attr('href')
                        if url && isScrolledIntoView('.pagination')
                                $('.pagination').text('Fetching more...')
                                $.getScript(url)
                
                $(window).scroll()

And in the index.js.erb file:

javascript
$('#all_pages').append('<%= j render(@pages) %>');
<% if (@pages.current_page < @pages.num_pages) %>
        $('.pagination').replaceWith('<%= j paginate(@pages) %>');
<% else %>
        $('.pagination').remove();
<% end %>

I used @pages.current_page < @pages.num_pages since I couldn't get the @pages.next? method working with collections. Hopefully it will work in a future release.