This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Base class | |
class DynamicHostMailer < ActionMailer::Base | |
def initialize method_name=nil, host, *args | |
@host = host | |
super method_name, *args | |
end | |
def url_options | |
# Host should be checked against a relevant whitelist, this is only an example | |
{ host: @host } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AssociationPrimaryKey | |
module ActiveRecord | |
private | |
def create_has_many_reflection(association_id, options, &extension) | |
options.assert_valid_keys( | |
:class_name, :table_name, :foreign_key, :primary_key, | |
:dependent, | |
:select, :conditions, :include, :order, :group, :limit, :offset, | |
:as, :through, :source, :source_type, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FlashHelper | |
def embed_flash swf, options={}, &block | |
outer_options = options.slice(:id, :width, :height).merge(:classid=>'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000') | |
inner_options = options.slice(:width, :height).merge(:type=>'application/x-shockwave-flash', :data=>swf) | |
params = options[:params] && options[:params].map {|name, value| tag(:param, :name=>name, :value=>value)}.join || '' | |
if block_given? | |
embed_flash_with_block swf, outer_options, inner_options, params, &block | |
else | |
embed_flash_without_block swf, outer_options, inner_options, params | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Drop the following in an initializer and enjoy consistency and less code when marking up forms. | |
# <% form_for @user do |f| %> | |
# <%= f.text_field :username %> | |
# <%= f.check_box :terms_accepted, :label=>'I accept the terms' %> | |
# <%= f.submit 'Save' %> | |
# <% end %> | |
# produces | |
# <form ...> | |
# <p> | |
# <label for="user_username">Username</label><br/> |