This file contains 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
<h1>A better way to manage HTML emails with Ruby on Rails</h1> | |
<p>With Transis Planner nearly completed, we're starting to focus on the finer details, making sure everything's nicely polished and ready for launch. Among other things, this means creating great looking HTML emails. After all, Planner is a collaboration tool. Our users will be working together to hammer out effective media plans, and that means we'll be sending lots of media briefs, insertion orders, and so on.</p> | |
<p>Sending multipart emails (i.e. HTML and plain text) with Rails is very straight forward. Just write a mailer action and create two corresponding view templates — one with an `.html` extension and one with a `.text` extension. But this method has a few shortcomings:</p> | |
<ul> | |
<li>You end up duplicating text (and probably logic) since you need to create both a `.text` and `.html` template.</li> | |
<li>Emails are a total pain to style. In the process, you'll lay waste to all sorts of web standards — using table-based la |
This file contains 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
# Iterative solution | |
# | |
bottles = (0..99).to_a | |
bottles.reverse.each do |bottle| | |
if bottle.zero? | |
puts "#{bottle} bottles of beer on the wall. No more beer" | |
else | |
puts "#{bottle} bottles of beer on the wall.." | |
end |
This file contains 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
ruby-1.9.2-p180@ignition[master]$ bundle exec rake spec:all | |
(in /Users/cory.schires/Desktop/work/ignition) | |
/Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/cucumber-rails-1.0.2/lib/cucumber/rails.rb:4:in `dirname': can't convert nil into String (TypeError) | |
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/cucumber-rails-1.0.2/lib/cucumber/rails.rb:4:in `<top (required)>' | |
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `require' | |
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `rescue in block in require' | |
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:62:in `block in require' | |
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each' | |
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require' | |
fr |
This file contains 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
# Starts with cucumber's built-in hashes method and adds a bit more magic: | |
# | |
# * Converts hash keys from stings to symbols | |
# * Converts numeric values into integers | |
# * Converts true/false strings into actual booleans | |
# | |
def hasherize(table) | |
table.hashes.map do |object| | |
object.each do |attribute, value| | |
object[attribute] = to_boolean?(value) |
This file contains 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
/** | |
* Event Title | |
* | |
* Return an event's title with pseudo-breadcrumb if on a category | |
* | |
* @param bool $depth include linked title | |
* @return string title | |
* @since 2.0 | |
*/ |
This file contains 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
ruby-1.9.3-p0@scholastica[master]$ rake staging heroku:deploy | |
/Users/coryschires/.rvm/gems/ruby-1.9.3-p0@scholastica/gems/heroku-rails-0.3.2/lib/heroku/rails/tasks.rb:3: warning: already initialized constant HEROKU_CONFIG_FILE | |
/Users/coryschires/.rvm/gems/ruby-1.9.3-p0@scholastica/gems/heroku-rails-0.3.2/lib/heroku/rails/tasks.rb:4: warning: already initialized constant HEROKU_CONFIG | |
/Users/coryschires/.rvm/gems/ruby-1.9.3-p0@scholastica/gems/heroku-rails-0.3.2/lib/heroku/rails/tasks.rb:5: warning: already initialized constant HEROKU_RUNNER | |
Deploying to scholastica-staging... | |
git push [email protected]:scholastica-staging.git master:master && heroku rake --app scholastica-staging db:migrate && heroku restart --app scholastica-staging | |
Everything up-to-date | |
/Users/coryschires/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault |
This file contains 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
ruby-1.9.2-head@scholastica[master*]$ heroku db:pull --confirm scholastica | |
Loaded Taps v0.3.23 | |
Auto-detected local database: postgres://127.0.0.1/eruditee_development?encoding=utf8 | |
Warning: Data in the database 'postgres://127.0.0.1/eruditee_development?encoding=utf8' will be overwritten and will not be recoverable. | |
Receiving schema | |
Schema: 0% | | ETA: --:--:-- | |
Schema: 3% |= | ETA: 00:00:44 | |
Schema: 7% |== | ETA: 00:00:37 | |
Schema: 11% |==== | ETA: 00:00:33 | |
Schema: 15% |====== | ETA: 00:00:30 |
This file contains 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
cache: [POST /conversation/questions/4/answers] invalidate, pass | |
Started POST "/conversation/questions/4/answers" for 127.0.0.1 at 2011-10-26 11:39:29 -0500 | |
Processing by Rostra::AnswersController#create as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"kMghcRVWRnEZHKdb5lE43qQ2uByACYLkcGLaR10Uvis=", "answer"=>{"user_id"=>"2164", "question_id"=>"4", "text"=>"<p>An answer</p>", "follow_by_email"=>"1"}, "commit"=>"Answer", "question_id"=>"4"} | |
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2164 LIMIT 1 | |
Role Load (0.7ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles"."id" = "roles_users"."role_id" WHERE "roles_users"."user_id" = 2164 AND "roles"."name" = 'super_admin' LIMIT 1 | |
Role Load (0.8ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles"."id" = "roles_users"."role_id" WHERE "roles_users"."user_id" = 2164 AND "roles"."name" = 'member' LIMIT 1 | |
Profile Load (0.4ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = 21 |
This file contains 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
# add to <tt>layout_helper.rb</tt>: | |
def rostra_page_title | |
case "#{controller_name}##{action_name}" | |
when "questions#show" then @question.title | |
when "questions#index" then | |
if params[:tag_search].present? | |
"Recent Questions" | |
else | |
"Recent Questions for tag #{params[:tag_search]}" | |
end |
This file contains 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
Question.where(created_at: (15.days.ago)..(Time.now)) | |
.limit(limit) | |
.joins(:impressions) | |
.group("impressions.impressionable_id") |