How to create a single page application in Rails?
source link: https://www.codesd.com/item/how-to-create-a-single-page-application-in-rails.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to create a single page application in Rails?
I'm creating my first Rails 3.2 application after completing the excellent Rails Tutorial.
I would like my application to do this:
Pull a random recipe from the database (I have finished this bit using the 'index' action and this bit of code: @recipe = Recipe.find(:first, :order => 'Random()'))
If the user clicks the 'something similar' button, the app fetches a related recipe from the db
If the user clicks 'something different', the app fetches an unrelated recipe
From what I understand, there should be an action for both 'something similar' and 'something different'. Is this correct?
Should I use a POST form with submit buttons for 'something different' and 'something similar' to determine which action to take?
Also, how can I keep the user on a single page throughout (so they always see the URL as http://www.whatshouldicookfordinner.co.uk rather than /recipes#somethingdifferent)?
To keep the user on the same page throughout, you will want to use AJAX. Check out this railscasts, you can apply the concept to what you are trying to do.
Related Articles
Creating a single page application using asp.net MVC4 and AngularJs
How to have a single page application without # in the URL using Angularjs?
Is it possible to create a single-page application using MongoDB as a backend?
How to configure a single-page application in Visual Studio 2010
How to implement a single page application that can work offline with Breeze.js and HTML5 local storage
What are the best practices for creating a single page application?
Django administration site: how to create a single page for global settings?
How to force update single page application (SPA) pages?
Dart: How to make a single-page application with multiple views
Creating a single page application with AngularJS and Sitecore (SPA)
Rails 3 - Design: how to create a single page to publish an article and Sigin + Registration
Use Node.js and ExtJS to create a single page application based on the company grid?
how to create a single web application as a subdomain for many businesses
How to create a real-time application with Rails?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK