6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails よく使うメソット集

Last updated at Posted at 2014-04-06
  request.request_uri
  # => "/entries"

  request.path_info
  # => "/entries"

  request.url
  # => "http://localhost:3000/entries"
  collection_select デフォルト表示
  :prompt => "デフォルト表示"

Rails 定数の呼び出し

Rails.root.to_s
=> インストールされているpath

Rails 日付や時間の取り扱い

Date.tomorrow
# => 明日
Date.yesterday
# => 昨日

console

Model.methods
# => そのModelの持っているMethod一覧を表示する。

scope

■joinしたときにwhere文
Shop.joins(:charge).where(charges: {user_id: 1})
# => SELECT `shops`.* FROM `shops` INNER JOIN `charges` ON `charges`.`shop_id` = `shops`.`id` WHERE `shops`.`deleted_at` IS NULL AND `charges`.`user_id` = 1

controller

before_filter
# => ActionMethodを呼び出す前に読み込む ActionMethod
around_filter
# => ActionMethodを呼び出す前後に読み込む ActionMethod
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?