RailsCasts Pro episodes are now free!

Learn more or hide this

Pranay's Profile

GitHub User: ipranay

Comments by Pranay


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


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


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


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


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:

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...')

And in the index.js.erb file:

$('#all_pages').append('<%= j render(@pages) %>');
<% if (@pages.current_page < @pages.num_pages) %>
        $('.pagination').replaceWith('<%= j paginate(@pages) %>');
<% else %>
<% 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.