You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
Rails での JSON API 実装まとめ 前後リンク RESTful API のおさらい Rails での JSON API 実装まとめ スキーマファースト開発 The NEXT of REST Ruby on JSON の図のような流れになるんですが、それぞれ見ていきます。 to_json (2011-2013 頃) 2011-2013 年頃、僕らは render :json を使っていました。 render json: @user render json: @user.to_json として User#as_json や User#to_json を利用します。 この頃はまだ SPA という言葉もなく、ネイティブアプリもそこまで流行っていなかったので これで十分だったのですが、どんどん API に世の中が寄っていき、限界を迎えます。 この頃のツラみ JSON を組み立てるのが大変
Google グループでは、オンライン フォーラムやメール ベースのグループを作成したり、こうしたフォーラムやグループに参加したりすることで、大勢のユーザーと情報の共有やディスカッションを行うことができます。
Posts Jan 16, 2024 Inline SVG in Ruby on Rails Nov 30, 2023 System.d service (daemon) for Puma server instaled under RVM (Rails) Apr 26, 2023 Update millions of records in Rails Jan 7, 2023 Responsive Navbar with Tailwind & Stimulus JS Dec 8, 2022 Responsibility On Rails Aug 16, 2022 Elasticsearch 7 under Ubuntu - protect with basic password May 9, 2022 Use Importmaps without Rails Apr 28, 2022 Si
One of the major requirements for any online business is to have a backend that either provides or can be extended to provide an API response. Building websites with static HTML and simple jquery ajax is coming to an end. In this era, Javascript frameworks rules the market. Hence, it is a good decision for the database to support JSON, as JSON is becoming the glue that connects the frontend and b
There is a world where developers need never worry about poorly formatted JSON. This is not that world. If a client submits invalid / poorly formatted JSON to a Rails 3.2 or 4 app, a cryptic and unhelpful error is thrown and they’re left wondering why the request tanked. Example errors The error thrown by the parameter parsing middleware behaves differently depending on your version of Rails: 3.2
TL;DR JSON Schemaを使ってこういうことが実現可能になった。 ダミーAPIサーバの提供 ドキュメントの自動生成 APIクライアントの動的定義 APIサーバのバリデータの動的定義 APIサーバのレスポンスの自動テスト JSON Schemaとは JSON SchemaというのはあるJSONのデータ構造を記述するための方法および書式の仕様で、 JSON SchemaもJSONで記述される。 これを利用すれば、リソースベースの(=RESTfulライクな)APIの仕様が簡便に記述できる。 例えば、我々のAPIはレシピとユーザというリソースを扱っていて、 それぞれCRUDのAPIを備えており、レシピはidとtitleとdescriptionという属性を持つ、 という旨をJSON Schemaで表現できる。 なんで最近ちょっと流行ってんの Mobile First、 Service Or
Ruby, Rails, Javascript | 02:04 | RubyからデータをJSON形式の文字列に変換する方法はいくつかありますが、Railsでアプリケーションを構築しているのであれば、ActiveSupport::JSONを利用するのが簡単だと思います。ActiveSupport::JSON.encodeメソッドを利用することによって、データをJSON形式の文字列に変換することができます。逆にJSON形式の文字列をデータに変換するにはdecodeメソッドを使います。 require 'rubygems' require 'active_support' data = {"id" => 3, "name" => "タマ"} json = ActiveSupport::JSON.encode(data) print json #=> {"name":"\u30bf\u30de",
yajl(Yet Another JSON Library)っていう高速なJSONライブラリがあって、 yajl こいつをrubyから使えるようにするyajl-rubyってgemがあって、これをMultiJsonのBackendに変更することで、RailsにおけるJSON処理の高速化が期待できるデス。 brianmario/yajl-ruby · GitHub 素のjson.gemと、yajl-rubyとで適当なActiveRecordオブジェクトからJSONへのエンコードと、その逆のデコードで簡単にベンチってみると、約2倍の差があることが分かる。 -------------------------------------------------------------------------------- Benchmark of json encoding/decoding json_
When I first embarked on creating an API for a project, I couldn’t find a ton of resources on how to test it with RSpec, so I decided to write a blog post about it. Let’s say we’re building an app that allows users to list their second bedrooms to short-term guests. We all love Airbnb :) This would be an application with many models that have complex associations, but let’s focus on what a host ca
source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.1' # Use Postgres as the database for Active Record gem 'pg' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.1.0' # See https://gi
samuelrodgers752 | Flickr - Photo Sharing! RoarはRepresenterを使ってRESTなAPIをパース、レンダーすることができるgemです。 つまり、Roarを使うことで、RailsでJSONを返すAPIサーバーを作成したり、逆に、APIサーバーにアクセスするAPIクライアントをRubyで作れます。 下記に記載しましたが、有名なgemに比べて、メリットとしては、Rubyでサーバーとクライアントを作る場合、同じような箇所を幾分か共有できる点です。 デメリットとしては、個人的にパースやレンダー時にエラーが発生してもデバッグしづらく対処しづらいことです。 サーバー側でAPIを作る場合、「Ruby Toolbox - API Builders」によると、jbuilderやGrape、Rablなどが人気のようです。 APIにアクセスするクライアントを作
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く