Reputation: 597
I'm creating a rails app with two columns. On one side is a journal log and the other is a set of various links and resources to internal pages. I'd like to be able to navigate to different pages of the journal log on the left side without changing the content on the right. I'd also like to navigate through pages on the right without changing what day of the log is being viewed.
This is very much like two separate html frames. Is there a proper way to do this in rails using rails routing?
Upvotes: 1
Views: 152
Reputation: 3639
If you need to replace just a section of one page without causing the whole page to reload, the modern solution is AJAX. (AJAX is the new frames, basically.) There's a whole science to this, but at a high level what you typically do is this:
request.xhr?
or a respond_to
block, the latter being somewhat more idiomatic.This can be complicated, but a Google search for jQuery and AJAX will point you in the right direction.
Upvotes: 0
Reputation: 15492
Basically in rails, the best way to do such things is to create a partial and share it whatever pages you want. Partials are small bits of html code which can be reused and rendered.
For example, the navigation can be made into partial and placed into the common layout file. That way it does change for any page using that layout.
http://guides.rubyonrails.org/layouts_and_rendering.html
Read above for more details
Upvotes: 1