3. Eager Loading
Associations
- Conditions on Eager Loaded Associations -
conditional ājoinsā > conditional āincludesā
Post.includes(:comments)
.where("comments.visible", true)
SELECT "posts"."id" AS t0_r0, ... "comments"."updated_at" AS t1_r5
FROM "posts"
LEFT OUTER JOIN "comments"
ON "comments"."post_id" = "posts"."id"
WHERE (comments.visible = 1)
ROR Lab.
4. Eager Loading
Associations
- Conditions on Eager Loaded Associations -
INNER JOIN LEFT OUTER JOIN
conditional ājoinsā > conditional āincludesā
Post.includes(:comments)
.where("comments.visible", true)
SELECT "posts"."id" AS t0_r0, ... "comments"."updated_at" AS t1_r5
FROM "posts"
LEFT OUTER JOIN "comments"
ON "comments"."post_id" = "posts"."id"
WHERE (comments.visible = 1)
ROR Lab.
5. Scopes
Passing in arguments
class Post < ActiveRecord::Base
Ā Ā scope :1_week_before,
lambda { |time| where("created_at < ?", time) }
end
class Post < ActiveRecord::Base
Ā Ā def self.1_week_before(time)
Ā Ā Ā Ā where("created_at < ?", time)
Ā Ā end
***What about āas a class methodā ?
ROR Lab.
6. Scopes
Passing in arguments
class Post < ActiveRecord::Base
Ā Ā scope :1_week_before,
lambda { |time| where("created_at < ?", time) }
end
le
eab
erclass Post < ActiveRecord::Base
ef
pr Ā Ā def self.1_week_before(time)
Ā Ā Ā Ā where("created_at < ?", time)
Ā Ā end
***What about āas a class methodā ?
ROR Lab.
17. HTML 5
Form Helpers
Rails 3 HTML5 Input Types
search_ļ¬eld search
telephone_ļ¬eld tel
url_ļ¬eld url
email_ļ¬eld email
number_ļ¬eld number
range_ļ¬eld range
Agile Web Development with Rails 4th edition
ROR Lab.
103. Complex forms
Railscasts by Ryan Bates
ā¢ Complex Forms Part 1 - Episode #73
ā¢ Complex Forms Part II - Episode #74
ā¢ Complex Forms Part III - Episode #75
ā¢ Nested Model Form (resivsed) - Episode #196
ROR Lab.