Code to Display text only on WordPress Blog Home Page

Cut and past php code to determine if it is the wordpress blog home page (and only the home page itself).

[php]<?php if (is_home() && !is_paged()): ?>[/php]

Example, to print john if it is a “homepage” templated page and jill otherwise:

[php]<?php if (is_home(); ?>

<?php
if($name == ‘john’){
echo ‘Hi John’;
}else if($name == ‘jill’){
echo ‘Hi Jill’;
}else{
echo ‘Hi’;
}
?>[/php]

Adding a Model in Ruby on Rails

for Rails 2.*
Not for Rails 3

How to add a model in rails

  • ./script/generate resource MODELNAME
  • [ruby]./script/generate resource article[/ruby]

  • edit migrate file
  • edit model.rb – to add associations and validations
  • edit controller.rb – add the 7 rest methods
  • rake db:migrate – to run the new migration
  • If you have to add a table (like a join table) you can do something like, for example
  • [ruby]./script/generate migration add_join_table_for_articles_and_authors[/ruby]

Update to the routes file should be taken care of by generate resource, but might want to check).