developers with a way to link their applications to backend cloud storage and APIs exposed by back end applications while also providing features such as user management, push notifications, and integration with social networking services." https://en.wikipedia.org/wiki/Mobile_backend_as_a_service
quando o usuário seleciona a cidade O sistema lista os tipos de cozinhas quando o usuário seleciona o bairro O sistema lista as features de acordo com os filtros selecionados anteriormente
slug: String neighborhood: String cuisine: String tags: String imagesArray: Array • Neighborhood guarda um valor Plain Text e que se repete em vários registros.
slug: String neighborhood: String cuisine: String tags: String imagesArray: Array • Ao ler o nome do campo entende-se que se trata do nome de uma única cozinha • Armazena diversos nomes de "Cozinhas" em Plain Text, cada nome separado por vírgulas: "American,BBQ,Sandwich,Pizza"
slug: String neighborhood: String cuisine: String tags: String imagesArray: Array • Na plataforma, tags são chamadas de "Features". • Novamente um campo Plain Text com itens separados por vírgulas: "Breakfast,Lunch,Delivery"
Reloading • Development Mode • Test Mode • Logging • Security • Parameter Parsing • Conditional GETs • HEAD requests Por que usar Rails para APIs JSON?
{name: "Accept", value: "application/json; version=1"}) do get '/cities', to: 'cities#index' end end $ curl -H "Accept: application/json; version=1" http://localhost:3000/cities
:user, presence: true before_create :generate_token, unless: :encrypted_token # Encrypt token when setting a new one def token=(new_token) @token = new_token self.encrypted_token = token_digest(@token) if @token.present? end # Check if token is the right one def valid_token?(token) return false if encrypted_token.blank? BCrypt::Password.new(encrypted_token) == token end private # Use bcrypt to encrypt token def token_digest(token) BCrypt::Password.create(token, cost: BCrypt::Engine.cost) end # Generate a token (being careful that it does not exit already) def generate_token send(:token=, SecureRandom.hex) generate_token if self.class.exists?(encrypted_token: encrypted_token) end end
users" do get "/users" assert_response :success refute_empty response.body users = JSON.parse(response.body, symbolize_names: true) assert_equal 2, users.size end end