Last active
January 4, 2019 02:04
-
-
Save edwardloveall/5a41d13d35bda28d74f0d2aebee06f2d to your computer and use it in GitHub Desktop.
preload association
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
class Me::Show < BrowserAction | |
get "/me" do | |
follows = FollowQuery.new.preload_from.to_id(current_user.id) | |
render ShowPage, follows: follows | |
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
class Me::ShowPage < MainLayout | |
needs follows : FollowQuery | |
def content | |
h3 "Email: #{@current_user.email}" | |
list_pending_follows(@follows) | |
end | |
private def list_pending_follows(follows : FollowQuery) | |
ul do | |
follows.each do |follow| | |
li "#{follow.from.email}" | |
end | |
end | |
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
from for Follow must be preloaded with 'preload_from' (LuckyRecord::LazyLoadError) | |
from src/models/follow.cr:3:5 in 'get_from' | |
from src/models/follow.cr:3:5 in 'from' | |
from src/pages/me/show_page.cr:12:15 in 'list_pending_follows' | |
from src/pages/me/show_page.cr:6:5 in 'content' | |
from src/pages/main_layout.cr:18:9 in 'render' | |
from lib/lucky/src/lucky/html_builder.cr:57:5 in 'perform_render' | |
from src/actions/me/show.cr:2:3 in 'call' | |
from lib/lucky/src/lucky/renderable.cr:84:16 in 'perform_action' | |
from lib/lucky/src/lucky/route_handler.cr:10:7 in 'call' | |
from /usr/local/Cellar/crystal/0.27.0/src/http/server/handler.cr:24:7 in 'call_next' | |
from lib/lucky/src/lucky/error_handler.cr:14:5 in 'call' | |
from /usr/local/Cellar/crystal/0.27.0/src/http/server/handler.cr:24:7 in 'call_next' | |
from lib/lucky/src/lucky/flash_handler.cr:5:5 in 'call' | |
from /usr/local/Cellar/crystal/0.27.0/src/http/server/handler.cr:24:7 in 'call_next' | |
from lib/lucky/src/lucky/session_handler.cr:7:5 in 'call' | |
from /usr/local/Cellar/crystal/0.27.0/src/http/server/handler.cr:24:7 in 'call_next' | |
from lib/lucky/src/lucky/log_handler.cr:19:7 in 'call' | |
from /usr/local/Cellar/crystal/0.27.0/src/http/server/handler.cr:24:7 in 'call_next' | |
from lib/lucky/src/lucky/http_method_override_handler.cr:11:5 in 'call' | |
from /usr/local/Cellar/crystal/0.27.0/src/http/server/request_processor.cr:39:11 in 'process' | |
from /usr/local/Cellar/crystal/0.27.0/src/http/server/request_processor.cr:16:3 in 'process' | |
from /usr/local/Cellar/crystal/0.27.0/src/http/server.cr:396:5 in 'handle_client' | |
from /usr/local/Cellar/crystal/0.27.0/src/http/server.cr:362:13 in '->' | |
from /usr/local/Cellar/crystal/0.27.0/src/fiber.cr:255:3 in 'run' | |
from /usr/local/Cellar/crystal/0.27.0/src/fiber.cr:75:34 in '->' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment