1

I have a Rails app that was working well until I upgraded ruby, rubygems, and my gems.

Almost all of my links are remote links. When I make the first request by clicking on one of these links, Fancybox is triggered and opens the new content correctly. When I close the box and click the same link again the request that is generated is completely different. It requests the index and consequently Fancybox is populated with the index response.

Sample link:

<a href="/companies/87/edit" data-remote="true">Handmade Design</a>

First request:

Started GET "/companies/89/edit" for 127.0.0.1 at 2013-03-18 15:34:26 -0700
Processing by CompaniesController#edit as JS

Second request:

Started GET "/companies" for 127.0.0.1 at 2013-03-18 15:34:26 -0700
Processing by CompaniesController#index as */*

I'm relying on the jquery-rails gem, fancybox, and the remotipart gem if that helps. Since these were all updated it seems like the error could be in one of these areas, but that fact that the requests are totally different makes me think it's something with Rails formats. Here is what the edit action looks like in the Companies controller:

#/controllers/companies_controller.rb
respond_to :html, :json
respond_to :js,   :only => [:new, :create, :edit, :update, :destroy]

# ...

# GET /companies/1/edit
def edit
  respond_with @company
end

I use a before filter to grab the company.

Any help or clues would be much appreciated.

UPDATE

The second request appears to always be a request for the current page.

UPDATE

I've isolated this to a JS issue. It appears to not be an issue with Rails or remote links.

David R
  • 328
  • 1
  • 15
  • i was also facing similar strange behaviour with fancybox! then I replaced this with colorbox. life is easier now. – HungryCoder Mar 18 '13 at 23:46
  • Thanks for the tip regarding colorbox but this app has been working without this issue for over a year. – David R Mar 18 '13 at 23:55

1 Answers1

0

I found the source of the issue. When Fancybox closes it doesn't correctly replace the HTML it is takes when it opens. The issue and some solutions are documented here:

Fancy box not opening iFrame second time

Community
  • 1
  • 1
David R
  • 328
  • 1
  • 15