##References
##Create Models
Create tables:
rails g model Location
rails g model User
rails g model Checkin
##References
##Create Models
Create tables:
rails g model Location
rails g model User
rails g model Checkin
| /* | |
| Distributed under The MIT License: | |
| http://opensource.org/licenses/mit-license.php | |
| Permission is hereby granted, free of charge, to any person obtaining | |
| a copy of this software and associated documentation files (the | |
| "Software"), to deal in the Software without restriction, including | |
| without limitation the rights to use, copy, modify, merge, publish, | |
| distribute, sublicense, and/or sell copies of the Software, and to |
| #include <SPI.h> | |
| #include <Ethernet.h> | |
| byte mac[] = { 0x00, 0xAB, 0xCB, 0xCD, 0xDE, 0x02 }; | |
| IPAddress ip(192,168,0,140); | |
| IPAddress server(173,194,70,103); | |
| EthernetClient client; |
| // | |
| // ARC Helper | |
| // | |
| // Version 2.2 | |
| // | |
| // Created by Nick Lockwood on 05/01/2012. | |
| // Copyright 2012 Charcoal Design | |
| // | |
| // Distributed under the permissive zlib license | |
| // Get the latest version from here: |
| # ... | |
| gem 'carrierwave' | |
| gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL |
| # app/models/ability.rb | |
| # All front end users are authorized using this class | |
| class Ability | |
| include CanCan::Ability | |
| def initialize(user) | |
| user ||= User.new | |
| can :read, :all |
| class Api::RegistrationsController < Api::BaseController | |
| respond_to :json | |
| def create | |
| user = User.new(params[:user]) | |
| if user.save | |
| render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
| return | |
| else |
APIs are becoming an essential feature of modern web applications. Rails does a good job of helping your application provide an API using the same MVC structure you're accustomed to.
Let's work with the following example controller:
class ArticlesController < ApplicationController| // | |
| // NSObject+Blocks.h | |
| // Filemator | |
| // | |
| // Created by Zachary Waldowski on 4/12/11. | |
| // Copyright 2011 Dizzy Technology. All rights reserved. | |
| // | |
| @interface NSObject (Blocks) |