Hello to all! I'm trying to learn Ruby on Rails here and I don't know how to properly search for errors. If everything was simple in PHP (either the compiler displays an error, or you look at what the variables contain, what this or that function returns, etc.), but on RoR everything is not so clear. Please tell me how you will debug your code. I installed Nginx and Thin, which my RoR project runs on.
First of all, I look at the console (if in the development process) or logs (if in work). Variables can be displayed both in the console (more convenient) and in the browser (for debugging views).
It is convenient to display with this gem: https://github.com/michaeldv/awesome_print
There was also somewhere here: http://railstutorial.ru/chapters/4_0/beginning
I'll add examples:
In the Gemfile:
group :development, :test do gem 'awesome_print' end
In controller (result to console):
def show @item = Model.find(id) ap @item #awesome_print puts @item #ruby standart end
View (result in the browser):
<%= ap(@item).html_safe %>
<%= debug @item %>
And Nginx with
thin not needed during development (sometimes it even interferes). Enough rails s (webrick).