strange! I am using ubuntu 16.04 and every thing is working correctly but I didn't saw anything like [ok] or "restarting nginx ... [ok]" like Chris does! weird :/
do you see the message "Restarting nginx nginx" when you type "sudo service nginx restart" ? In my case I don't see it and Chris said that something gonna be wrong if you don't see it.
Hi Chris, when I do sudo service nginx restart it doesn't show anything, you say that this might be an error, I did sudo tail /var/log/nginx/error.log but I can't see any error there! this is the output :
[ 2016-07-09 12:46:04.5741 23679/7f3c412f4700 Ser/Server.h:464 ]: [UstRouter] Shutdown finished
[ 2016-07-09 12:46:04.5743 23679/7f3c47f47780 age/Ust/UstRouterMain.cpp:523 ]: Passenger UstRouter shutdown finished
[ 2016-07-09 12:46:04.5939 23674/7f3bb0d6f780 age/Cor/CoreMain.cpp:967 ]: Passenger core shutdown finished
2016/07/09 12:46:05 [info] 23783#23783: Using 32768KiB of shared memory for push module in /etc/nginx/nginx.conf:75
[ 2016-07-09 12:46:05.7251 23790/7f341ddf1780 age/Wat/WatchdogMain.cpp:1291 ]: Starting Passenger watchdog...
[ 2016-07-09 12:46:05.7624 23793/7fdc2184b780 age/Cor/CoreMain.cpp:982 ]: Starting Passenger core...
[ 2016-07-09 12:46:05.7625 23793/7fdc2184b780 age/Cor/CoreMain.cpp:235 ]: Passenger core running in multi-application mode.
[ 2016-07-09 12:46:05.7646 23793/7fdc2184b780 age/Cor/CoreMain.cpp:732 ]: Passenger core online, PID 23793
[ 2016-07-09 12:46:05.8046 23798/7f724a019780 age/Ust/UstRouterMain.cpp:529 ]: Starting Passenger UstRouter...
[ 2016-07-09 12:46:05.8060 23798/7f724a019780 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 23798
by the way when I opened /etc/nginx/nginx.conf the first time, I haven't find the lines passenger_ruby and passenger_root
That's awesome, Thank you Chris I never thought a such thing exists... But does this work for all libraries ? after watching the video I tried rails-assets-ckeditor but it seems that I am getting errors like ActionController::RoutingError (No route matches [GET] "/lang/en.js"): ........
This episode is more clear, I can see why you had that performance problem, your solution is the best in this case, but I think I know why step.course does trigger the database each time because I deal many times with eager loading in the past! let's imagine you only eager load "steps" like this @course.sections.includes(:steps) , in this case the requests are : 1- it fetch * from sections where the course_id equal @course.id then 2- it fetch * from steps for **each** section (but it doesn't fetch the course for each step, so just I may told you before, if you do steps: :product which I now it's redundant and inefficient because you already have @course then you will not have the performance problem); I don't know if my explanation is clear but in general : steps are loaded for each section, so: @course.sections.find(3).steps or even @course.sections.find(3).steps.find(5) will not trigger the database, but if you try to do the inverse and access @course from a step then obviously it will trigger the database. I hope I am not confusing this time!
sorry that I was not be able to understand :( it may be clearer for me if I can see how the controller handle that, but you don't have to record the video again if I am the only one who don't understand, you can wait until seeing what others say! :)
I watched the video again trying to understand... what I understand from you is that you already had @course in the controller but you didn't use until discovered the performance issue ! also you loaded sections, steps and privacy through the course. What I was saying is if you eager load the course through the step it will not produce that problem.
Hi Chris, this issue is called N+1 problem and one of the ways to face it is by doing "eager loading" because sometimes you still need to use your step object in the view, so in the controller it's just simple as doing something like that : @steps = Step.all.includes(:course), you can even go deeper : I don't remember the syntax exactly but it's something like that steps.all.includes(course: [:other, :category, ....]), sometimes when you need more complex query you should use join instead of includes... I had the issue a long time ago when I wanted to implement an activity feed where every post has to bring the author and the comments for that post and also the users who write the comments...
Kohl Kohlbrenner to eliminate subdomains like www and admin I do something like this : Account.find_by(subdomain: request.subdomain) if (request.subdomain.present? && !["www", "admin"].include?(request.subdomain))
Also you don't have to tell your routes that you are using subdomains, the web server know about your url and it's enough to get the subdomain by using the "request" object which is provided by Rails.