Last active
January 2, 2016 03:49
-
-
Save bunnymatic/8246072 to your computer and use it in GitHub Desktop.
active_model_conversion blog post assets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the hot stuff wrapper/presenter | |
class HotStuff | |
def items | |
@items ||= Stuff.hot.limit(5) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ in app/views/hot_stuffs/_hot_stuff.slim | |
h1 this is hot | |
ul.hot_stuff | |
- @hot_stuff.items.each do |hot| | |
li = hot.snippet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in app/controllers/pages_controller.rb | |
class PagesController < ApplicationController | |
... | |
def welcome | |
@hot_stuff = Stuff.hot.limit(5) | |
@recent_activity = Activity.recent.limit(5) | |
... | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def welcome | |
@hot_stuff = HotStuff.new | |
@recent_activity = RecentActivity.new | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/pages_controller.rb | |
def welcome | |
@homepage_blocks = [HotStuff.new, RecentActivity.new] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ in app/views/pages/index.slim | |
.main | |
section.block | |
h1 this is hot | |
ul.hot_stuff | |
- @hot_stuff.each do |hot| | |
li = hot.snippet | |
section.block | |
h1 this is recent | |
ul.recent_activity | |
- @recent_activity.each do |recent| | |
li = recent.snippet | |
... etc ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ app/pages/index.html.slim | |
.main | |
section.block | |
== render @hot_stuff | |
section.block | |
== render @recent_activity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ app/pages/index.html.slim | |
.main | |
section.block | |
- @homepage_blocks.each do |block| | |
== render block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the recent activity wrapper | |
class RecentActivity | |
def items | |
@items ||= Activity.recent.limit(5) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ in app/views/recent_activities/_recent_activity.slim | |
h1 this is recent | |
ul.recent_activity | |
- @recent_activity.items.each do |recent| | |
li = recent.snippet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment