11

How to create a single page application in Rails?

 3 years ago
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?

advertisements

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

Hi, I am trying to create a single page application using AngularJs and Asp.net MVC4. To start off, I tried to do basic navigation using angular. I followed below steps. Create MVC4 web application, Selected internet application, Downloaded AngularJs

How to have a single page application without # in the URL using Angularjs?

I am trying to build an single page application with angular js. But i don't want # inside the url when the template is included. I have used the $locationProvider.html5Mode(true) app.config(['$routeProvider', '$locationProvider', function ($routePro

Is it possible to create a single-page application using MongoDB as a backend?

I am trying to use the new single page application project from the upcoming Visual studio and I was wondering if it would be possible to create an application using a MongoDB backend for the DBContext. It seems that the upshot.js library relies heav

How to configure a single-page application in Visual Studio 2010

I've read about Single-Page Applications recently and wanted to try one out. After watching Steve Sanderson's presentation (http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2159) I wanted to create a Single-Page App in my Visual

How to implement a single page application that can work offline with Breeze.js and HTML5 local storage

I have working Single Page Application using Breeze.js for Data Access. It uses the Breeze.js to execute queries against the local cache and the data is requested only once at start up. Only the data updates are posted back on the server afterwards.

What are the best practices for creating a single page application?

What are the most important things not to forget or consider when creating a single page app(completely ajax depended) in general? Or any specific consideration on MVC?For complex projects consider js library - Backbone http://documentcloud.github.co

Django administration site: how to create a single page for global settings?

I would like to create a single page in the admin site of django where I can change some global variables of the website (title of the website, items in the navigation menu, etc). At the moment I have them coded as context processors but I would like

How to force update single page application (SPA) pages?

In fully server side based rendering (non Web 2.0), deploying server side code would directly update client side pages upon page reload. In contrast, in React based Single Page Application, even after React components were updated, there would be sti

Dart: How to make a single-page application with multiple views

I am migrating from GWT to Dart and would like to take the MVP pattern that I learned from building GWT apps and use them in Dart-land. I'm playing around with my first Dart app and would like it to be a "single-page" app, meaning that the view

Creating a single page application with AngularJS and Sitecore (SPA)

I want to implement Sitecore application (single page design with angular js) : Is that possible ? If it is possible, what about experience editor, it will work with it ? What about Sitecore personalization ? I have no experience with angular js. wha

Rails 3 - Design: how to create a single page to publish an article and Sigin + Registration

I have the following relationship User --> has_many: Articles Article --> belongs_to: User I need to create a public (not restricted) page to Publish an Article (with Title & Description), in the same page I need to add the SignIn / SignUp form

Use Node.js and ExtJS to create a single page application based on the company grid?

While the title suggests I wanted to cram as many buzzwords into the question as possible, I am actually serious ;) I am exploring my options for building an enterprise application that will have plenty of grids and needs to be as snappy as a desktop

how to create a single web application as a subdomain for many businesses

i am working on a project that you can subscribe with your company name and you can use all features of site specificly to your company. for example company abcd can get its own url from our website like www.test.com/abcd/productlist.aspx company efg

How to create a real-time application with Rails?

I know there is a cool thing named Socket.io, but I want to build my app on Rails. I searched on web and found some result: EventMachine : looks like pure ruby. Maybe it can be embedded in Rails, but I have no idea how to do it. Juggernaut : someone

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK