Digital Notepad

Internet, Mobility and Serious Geekery

Ruby on Rails Concepts I Didn’t Get Before

October10

The Rails generator is only used for database-backed models.

Private keeps a method from being an action.

After every action rails tries to call a view (named after the action) in the corresponding controller’s folder.

Every request from the browser kills any instance variables around.

Abstract display processing doesn’t go in the view, it goes in the helper.

As much code as possible goes into the model; everything that knows about the view - and is plumbing of some kind - goes in the controller.

There’s an easy way to remember where to put belongs_to declarations: if a table has foreign keys, the corresponding model should have a belongs_to for each.

Remember:

  • variable_names_like_this
  • ConstantsWorkLikeThis
  • ClassesAreBasicallyTheSame
  • ModulesMixedCase
  • database_table_names_are_always_plurals
  • files_names_as_variables.html.erb

For debugging use:

<%= debug(@object_to_display) %> in html

Use script/console to hunt down model errors in applications’ context.

Use breakpoint by calling debugger and starting the server with -u argument. Explode the app and continue with cont.

posted under Tech

Email will not be published

Website example

Your Comment: