JSON is shown instead of HTML for viewing rails using ember.js

I am slowly moving my website with rails from a traditional return route application for all kinds, which will ultimately be based on a single ember.js page. As part of this migration, I do it step by step and I do not transfer the entire application at a time to a single-page application, but first in sections.

I exaggerate one problem that seems common. When I use the same controller for JSON views as well as for HTML views, clicking back in Chrome sometimes shows me a JSON view instead of an HTML view.

For example, I have an endpoint / portfolio / 13, which is the entry point to one of these sections of ember.js applications and which causes Ember Data to output JSON for the portfolio with identifier No. 13 on the same endpoint with the / json application as the header Accept :. Tapping back after redirecting to a deeper page will get a JSON representation of the page instead of HTML.

Do I need to force Ember Data to use a format parameter so that the JSON version has a different URL? If so, how to do it?

What am I doing wrong?

+5
source share
2 answers

Try adding this somewhere in your Javascript:

$.ajaxSetup({cache: false});

. - , JSON. , - , Rails JSON HTML.

+3

, "/json" rails? content-type: value?

"" JSON? ( HTML)

, ( ):

before do 
    content_type 'application/json'
end

, , "text/html" HTML-.

rails. ( ember?)

+1

All Articles