Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?
      
  
  
  http://qiita.com/kbaba1001/items/e265ad1e40f238931468 で Rails のアーキテクチャを改善する話を書きましたが、理屈っぽい話になっていたので、今回は具体例として実際に私が仕事で実践していることについて書きます。 半年ほどサービス層を作りまくっていますが、最高としか言いようがありません。 Modelとロジックが切り離されているので、本番運用をはじめた後もかなり柔軟に開発を続けられています。 (さすがにERに影響がある変更には手を焼きますが...) サービス層を作って Fat Model 対策をすることは Rails 開発において有効な設計だと感じています。 Rails にサービス層を導入する最も簡単でパワフルな手段は Trailblazer を使うことです。 しかし、本記事では Reform を使ってサービス層を自作する方法について書き
      
  In our previous post, The Basics of MVC in Rails, we discussed theoretical aspects of the MVC design pattern. We defined what MVC stands for, identified what each MVC component is responsible for, addressed what happens when a component contains redundant logic, and, most importantly, we introduced the concept of refactoring. In this article, as promised, we’ll show you each design pattern at work
      
  When I wrote about good modules and bad modules, I mentioned that an indication of a "bad" module was when it was used to extract code for the sake of code extraction. This usually results in a module that is only being mixed into one class. When I published the article, I had lots of support from people intimately familiar with the internals of many popular libraries like Active Record, agreeing
      
  Introduction Let’s consider a hypothetical situation — You’ve been working on a Rails application for about a year. When the application was new and its functionality limited, you could add features relatively simply by spinning up a new controller, model and view or — worst case — add a few lines to an existing controller, model or view. However, as time went by, the application’s feature set kep
      
  In Ruby, all functions are methods, so the terms “function” and “method” are interchangeable in this article. In this article, I want to demonstrate a nice way to write functional-style code in Ruby. It is a way to write non-trivial pure functions, without a bunch of weird non-idiomatic code. I’ll start by defining what pure functions are, explaining their benefits, and then walk through an exampl
99 Bottles of OOP is a practical guide to writing cost-effective, maintainable, and pleasing object-oriented code. Now available in Python, as well as JavaScript, PHP, and Ruby! It explores: Recognizing when code is "good enough" Getting the best value from Test-Driven Development (TDD) Doing proper refactoring, not random "rehacktoring" Locating concepts buried in code Finding names that convey d
Photo by Flickr: amatsuscribbler's Photostream awesome_nested_setとは、モデルを階層構造に管理できるようにするgemです。 フォルダ階層、カテゴリ階層、コメントへのリプライでの階層などツリー構造を表したい箇所で使うと便利です。 今回は、次のように、モデルを階層構造で表示、作成、更新できるようにします。 動作確認 Ruby 2.1.2 Rails 4.2.0 awesome_nested_set 3.0.2 バージョン3は「Rails 4」をサポート、バージョン2は「Rails 3」をサポート、2.0以前は「Rails 2」をサポートしています。 目次 awesome_nested_setのインストール awesome_nested_setの基本的な使い方 awesome_nested_setでカテゴリを階層構造にする 1. a
      
  One of the features of Ruby that can cause some confusion is that just about everything is an expression. This means that nearly everything that can return a value, does. This leads to some very interesting and sometimes confusing code. The previous example is contrived because you would typically write it using the ternary operator, but you get my point. Things get even more interesting when it c
Ruby on Rails 8.0.3 Module ActiveRecord::Aggregations::ClassMethods activerecord/lib/active_record/aggregations.rb Active Record Aggregations¶ ↑ Active Record implements aggregation through a macro-like class method called composed_of for representing attributes as value objects. It expresses relationships like “Account [is] composed of Money [among other things]” or “Person [is] composed of [an]
3年ほどRailsを書いてきてある程度知見が溜まってきたので、忘れないためのメモとしてKPTと導入例を交えながらダラダラと書いています。 見出しの命名規則は クラス名/ディレクトリ名の単数形をupper camel caseにしたもの + KPT です。 Keepは今後も使うもの、Problemは開発規模によっては問題が発生する(した)もの、Tryは現在使用していないが使用したほうが良いと思っているものです。 これらすべてを導入すれば上手くいくというわけでもないので、開発規模に合わせて適切に採用していくと良いと思います。 DDDやデザインパターン等見聞きはしているものの詳しいわけではないので間違っている部分等あるとは思うのでその辺りはコメントでご指摘お願いします。 はてブコメント欄で頂いた指摘内容等についてはまとめの後でまとめて返答を記載しています。 Asset (Keep) app/as
Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? 経緯 casyというインターネットを使って手軽に家事代行を頼むことができるサービスのプログラマをしています。 Webだけでなく、スマホアプリも出すことにあたり、Webアプリサーバ(Rails)から機能を切り出し、APIサーバ(Rails)を別途作成し、Webアプリの場合はWebアプリサーバからAPIサーバを呼び出し、アプリからは直接APIサーバを呼び出すような仕組みにしました。 ただ、全部の機能をAPIサーバに移すのは容易なことではなかったため、いくつかの機能はまだWebアプリサーバに残っていて、アプリよりもWebのほうが機能が多い状態
      
  リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く