Flowdock

Good notes posted by spectator

RSS feed
October 15, 2009
4 thanks

Have check_box checked by default

In addition to comment below, you can make a column with default value so in your forms it will be enabled by default and behave correctly with validation errors unlike :checked => true

in your migration

add_column :accounts, :ssl_enabled, :boolean, :default => 1
July 24, 2008
8 thanks

render template file different from your action (method) name

In some cases you have to avoid rails magic that uses template names named as your ActionMailer method.

rails magic

def daily_notification
  # ...
end
# will look for daily_notification.erb

def weekly_notification
  # ...
end
# will look for weekly_notification.erb

your case

Just give necessary value to @template instance variable.

def setup
  # ...
  @template = 'notification'
end

def daily_notification
  # ...
end
# will look for notification.erb

def weekly_notification
  # ...
end
# will look for notification.erb