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
| require 'PaymentProvider' # Loads "PaymentProvider.dll", a library written in C# | |
| invoice = PaymentProvider::EmailInvoice.new | |
| result = invoice.send_to(@order.email) |
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
| String.Join(", ", OrderLines.select(x => x.Product.name)); |
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
| products.collect(&:name).to_sentence |
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
| class ActionView::Helpers::FormBuilder | |
| private | |
| # PATCH: This is a patch of bug in Rails 3 beta 3, and should be removed when we move to Rails 3 final | |
| def fields_for_with_nested_attributes(association_name, args, block) | |
| name = "#{object_name}[#{association_name}_attributes]" | |
| options = args.extract_options! | |
| association = args.shift | |
| association = association.to_model if association.respond_to?(:to_model) |
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
| def link_to_add_fields(name, f, association) | |
| new_object = f.object.class.reflect_on_association(association).klass.new | |
| fields = f.fields_for(association, [new_object], :child_index => "new_#{association}") do |builder| | |
| render(association.to_s.singularize + "_fields", :f => builder) | |
| end | |
| link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")")) | |
| 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
| task :deploy => ['deploy:push', 'deploy:restart', 'deploy:tag'] | |
| namespace :deploy do | |
| task :migrations => [:push, :off, :migrate, :restart, :on, :tag] | |
| task :rollback => [:off, :push_previous, :restart, :on] | |
| task :push do | |
| puts 'Deploying site to Heroku ...' | |
| puts `git push heroku` | |
| 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
| module BccAllMails | |
| BCC_ALL_EMAILS_TO = "[email protected]" | |
| def self.included(base) | |
| base.class_eval { | |
| include InstanceMethods | |
| alias_method_chain :deliver!, :bcc_all_mails | |
| } | |
| 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
| task :deploy do | |
| puts 'Deploying site to Heroku ...' | |
| puts `git push heroku` | |
| puts 'Running database migrations ...' | |
| puts `heroku rake db:migrate` | |
| release_name = "release-#{Time.now.utc.strftime("%Y%m%d%H%M%S")}" | |
| puts "Tagging release as '#{release_name}'" | |
| puts `git tag -a #{release_name} -m 'Tagged release'` |
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 SiteExtension | |
| def self.included(base) | |
| base.class_eval { | |
| extend ClassMethods | |
| } | |
| end | |
| module ClassMethods | |
| # We only have one site, and we want to use that whatever the url might be |
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
| def authenticate_or_request_admin | |
| logged_in_as_admin || authenticate_or_request_with_http_basic { |username, password| login_as_admin(username, password) } | |
| end | |
| def logged_in_as_admin | |
| session_enabled? && session[:is_admin?] | |
| end | |
| def login_as_admin(username, password) | |
| authentic = username == ApplicationSettings::Administration::Authentication::USERNAME && |