method
from
v4.2.7 -
Show latest stable
- Class:
ActiveRecord::QueryMethods
from(value, subquery_name = nil)public
Specifies table from which the records will be fetched. For example:
Topic.select('title').from('posts') # => SELECT title FROM posts
Can accept other relation objects. For example:
Topic.select('title').from(Topic.approved) # => SELECT title FROM (SELECT * FROM topics WHERE approved = 't') subquery Topic.select('a.title').from(Topic.approved, :a) # => SELECT a.title FROM (SELECT * FROM topics WHERE approved = 't') a
2Notes
How to user method from'
==== example
User.from('posts').to_sql
# => "SELECT users.* FROM posts"
How to user method 'from'
==== example
User.from('posts').to_sql
# => "SELECT users.* FROM posts"