Rails 3: Difference between revisions

From Wiki
Jump to navigation Jump to search
Line 31: Line 31:
logger.info "info message"
logger.info "info message"
logger.warn "something bad"
logger.warn "something bad"
logger.error "bad"
logger.error "something broke"
logger.fatal "application dead"
logger.fatal "application dead"
</pre>
</pre>

Revision as of 18:57, 16 February 2011

Application Setup

  • create project with
rails new my_project
  • add gem dependencies to Gemfile at the root level
  • update config/application.rb to load needed dependencies and update defaults
  • double-check /config/initializers and /config/environments

Files in lib/ are not automatically loaded, so you need to require them.

In config/environments/development.rb, set

config.action_mailer.perform_deliveries = false

No delivery attempt is performed, but you can still see the mail in the log file to check it looks good


Other rails commands

rails console
rails server
rails runner


Logging

Use these in models, views, controllers to send timestamped messages to the log.

logger.debug "debug message"
logger.info "info message"
logger.warn "something bad"
logger.error "something broke"
logger.fatal "application dead"