To debug non Rails apps insert require debugger at the beginning of your

To debug non rails apps insert require debugger at

This preview shows page 155 - 158 out of 517 pages.

To debug non-Rails apps, insert require ’debugger’ at the beginning of your app. Summary Use a language-aware editor with syntax highlighting and automatic indentation to help find syntax errors. Instrument your app by inserting the output of debug or inspect into views, or by making them the argument of raise , which will cause a runtime exception that will display message as a Web
Image of page 155
page. To debug using the interactive debugger, make sure your app’s Gemfile includes debugger , start the app server with rails server --debugger , and place the statement debugger at the point in your code where you want to break. Self-Check 4.5.1. Why can’t you just use print or puts to display messages to help debug your SaaS app? Unlike command-line apps, SaaS apps aren’t attached to a terminal window, so there’s no obvious place for the output of a print statement to go. Self-Check 4.5.2. Of the three debugging methods described in this section, which ones are appropriate for collecting instrumentation or diagnostic information once your app is deployed and in production? Only the logger method is appropriate, since the other two methods (“stopping the show” in a controller or inserting diagnostic information into views) would interfere with the usage of real customers if used on a production app. 4.6 Form Submission: New and Create Our last look at views will deal with a slightly more complex situation: that of submitting a form, such as for creating a new movie or updating an existing one. There are three problems we need to address: 1. How do we display a fill-in form to the user? 2. How is the information filled in by the user actually made available to the controller action, so that it can be used in a create or update ActiveRecord call? 3. What resource should be returned and displayed as the result of a RESTful request to create or update an item? Unlike when we ask for a list of movies or details about a movie, it’s not obvious what to display as the result of a create or update. Of course, before we go further, we need to give the user a way to get to the fill-in form we’re about to create. Since the form will be for creating a new movie, it will correspond to the RESTful action new , and we will follow convention by placing the form in app/views/movies/new.html.haml . We can therefore take advantage of the automatically-provided RESTful URI helper new_movie_path to create a link to the form. Do this by adding a single line to the end of index.html.haml : 1 -# add to end of index.html.haml 2 3 = link_to ’Add new movie’, new_movie_path What controller action will be triggered if the user clicks on this link? Since we used the URI helper new_movie_path , it will be the new controller action. We haven’t defined this action yet, but for the moment, since the user is creating a brand-new movie entry, the only thing the action needs to do is
Image of page 156
cause the corresponding view for the new action to be rendered. Recall that by default, every controller method automatically tries to render a template with the corresponding
Image of page 157
Image of page 158

You've reached the end of your free preview.

Want to read all 517 pages?

  • Spring '19
  • Dr.Marcos

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors