Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bendyworks/ionic-rails-app
An example Ionic app to communicate with Rails.
https://github.com/bendyworks/ionic-rails-app
Last synced: 28 days ago
JSON representation
An example Ionic app to communicate with Rails.
- Host: GitHub
- URL: https://github.com/bendyworks/ionic-rails-app
- Owner: bendyworks
- License: apache-2.0
- Created: 2015-06-25T18:44:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-25T19:07:28.000Z (over 9 years ago)
- Last Synced: 2023-04-18T07:41:19.620Z (over 1 year ago)
- Language: HTML
- Size: 1.61 MB
- Stars: 20
- Watchers: 24
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ionic + Rails
This is code to accompany a screencast about making Rails and Ionic play nicely
together.## Getting started
Create a folder to hold both sides of the app
```
mkdir ionic-rails
cd ionic-rails
```## Rails
Perform these steps from within the `ionic-rails` folder you created.
Create the Rails project
```
rails new server
cd server
```Add `rack-cors` to the `Gemfile`
```
gem 'rack-cors'
```Run Bundler to refresh your gem store
```
bundle install
```Enable CORS in `config/application.rb`
```
# put this inside the Application class
config.middleware.insert_before 0, "Rack::Cors" do
allow do
origins '*'
resource '*', :headers => :any, :methods => [:get, :post, :options]
end
end
```Create the User scaffold
```
rails g scaffold user firstname:string lastname:string shirtSize:string vegetarian:boolean
```Allow CORS requests to come through in `app/controllers/user_controller.rb`
```
protect_from_forgery with: :null_session
```
(you can also do this in ApplicationController, but that is app-wide and is not a
great idea..)Run the Rails migrations
```
rake db:migrate
```Start the Rails server (in its own terminal)
```
rails s
```## Ionic
Perform these steps from within the `ionic-rails` folder you created.
Bootstrap from Ionic Template
```
ionic start app https://github.com/bendyworks/ionic-rails-app
```Start ionic server
```
cd app
ionic serve
```