27 Nov '15, 12pm

ruby: Rails Modelのscopeとlambda - Qiita https://t.co/couopn1OTh

ruby: Rails Modelのscopeとlambda - Qiita https://t.co/couopn1OTh

#Modelのscopeとは? Modelのscopeとは「共通のクエリの処理を設定し、それをメソッドのように使えるようにする機能」です。 例えば、下記のように公開日に達した記事だけを取り出すとします。 ```rb class ArticlesController < ApplicationController def index @articles = Article.where("published_date < ?", Time.now()) end end ``` この公開日に達した時だけ取り出すという処理は何度も出てくるかもしれません。このときこの処理を共通処理としてまとめます。 ```rb class ArticlesController < ApplicationController scope :published, -> { where("published_date < ?", Time.now()) } def index @articles = Article.published end end ``` このように、.publishedをメソッドの要領で使うことが出来て便利です。 これがModelのscopeです。 #Modelのscope使い方 上記にもあるように基本は ```rb class ArticlesController < ApplicationController scope :published, -> { where("published_date < ?", Time.now()) } def index @articles = Article.published end end ``` のように使います。 ##引数を渡す 例えば、以下のようにある日時以降の記事を取り出したいとします。 ```rb class ArticlesController < ApplicationController def index @articles = Article.where("published_date...

Full article: http://qiita.com/shizuma/items/fe695fe8a07aee031f01

Tweets

おーこれ読んでたら、ElasticSearchどう使えばいいのか形が見えてきた / “Ruby - 既存のRailsアプリの検索にElasticSearchを導入してみる - Qiita” https://t.co/Z6MXMwceTd

おーこれ読んでたら、ElasticSearchどう使えばいいのか形が見えてきた / “Ruby...

qiita.com 26 Nov '15, 10pm

Greenという転職サイトで、ElasticSearchを導入して遊んでみようと思います。 具体的には今の求人が持っているデータをElasticSearchに入れてみて実際に開発環境で動かす事をGoalとします。 ## 全文検索とは? 全文検索...

Rails 5 Basics : Hello Rails https://t.co/8rFsS...

rubyflow.com 27 Nov '15, 12am

× The Ruby and Rails community linklog Made a library? Written a blog post? Found a useful tutorial? Share it with the Rub...

“upload - Ruby on Rails で画像をアップロード(paperclip, fog) - Qiita” https://t.co/mNwrElaVUj

“upload - Ruby on Rails で画像をアップロード(paperclip, f...

qiita.com 22 Nov '15, 5pm

### [>>> サンプルアプリケーションはこちらです <<<](https://renshu-upload-image.herokuapp.com/) # 今日は Ruby on Rails で画像をアップロード出来るサイトの作り方をご紹介さ...

Choosing my editor for Ruby on Rails https://t.co/a0YbfPWfiy

Choosing my editor for Ruby on Rails https://t....

davidmles.com 26 Nov '15, 1pm

It does not recognise Rails files, opening them always as Ruby files. I have put a command in the configuration file so it...

Angular JS and Ruby on Rails Developer by kruna...

freelancer.com 28 Nov '15, 7am

Skills Required Angular.js Ruby on Rails Project Budget $8 - $15 USD / hour Total Bids 3 Project Description Require Ruby ...

Ruby on Rails Software Developer, 80 -100% at: ...

jobs.rubynow.com 27 Nov '15, 7pm

Simplificator solves complex Problems in an easy way. We collaborate closely with our customers from the Idea to the devel...

#eBookDe Ruby on Rails Bible https://t.co/wg0ajIeBgg

#eBookDe Ruby on Rails Bible https://t.co/wg0aj...

ebookde.com 28 Nov '15, 4am

Thanks to the explosive growth in popularity of the Rails framework, the equally popular Ruby programming language now has...

The Professional Ruby on Rails Developer #udemy...

udemy.com 26 Nov '15, 8pm

** Course updated August 2015!! ** Now with over 10,000 students enrolled! The Professional Ruby on Rails Developer Course...

[Rails] TwitterBootstrapとSassとAssetPipeline - Qiita: Ruby on Rails Tutorialのエッセンスを自分なりに整理してみる5 [Ruby基礎]… https://t.co/xgaJSzNUF5 [ruby]

[Rails] TwitterBootstrapとSassとAssetPipeline - Q...

qiita.com 05 Dec '15, 3am

Ruby on Rails Tutorialのエッセンスを自分なりに整理してみる5 [Ruby基礎] ブロックとProcをちゃんと理解する http://qiita.com/kidachi_/items/15cfee9ec66804c3afd2...

Fix bug in login in ruby on rails site by ddraz...

freelancer.com 28 Nov '15, 6pm

Project Budget €30 - €250 EUR Total Bids 5 Project Description Fix bug in login in ruby on rails site Looking to make some...

Remote job: Ruby on Rails Developer at A Hundre...

jobmote.com 28 Nov '15, 10pm

You have a Github account and are following some interesting projects and people. Even better if you have some public proj...

#workfromhome Integrate Design to Ruby on Rails...

freelancer.com 25 Nov '15, 1pm

We got a ticketing application in Ruby On Rails, now we need to customize its UI for the Agents and the customers. We will...

hi. i'm giving a training in january on ruby on...

eventbrite.com 25 Nov '15, 2pm

Rails combines the Ruby programming language with HTML , CSS , and JavaScript to create a web application that runs on a w...

Hey! @stuk_io is looking for a Ruby on Rails En...

landing.jobs 24 Nov '15, 4pm

We're looking for a kickass Ruby on Rails developer to join our awesome team at this lovely city called Porto. If you're c...

Rails 5 Basics : Model: Read the third chapter ...

rubyflow.com 28 Nov '15, 1am

× The Ruby and Rails community linklog Made a library? Written a blog post? Found a useful tutorial? Share it with the Rub...