-
Using Heroku to host your Rails CMS
16 March 2010
I love Heroku. Their awesome Ruby hosting eliminates the system admin stuff that developers hate. But until recently it has been difficult to let users have a rich javascript editor for pages/posts because you can't upload files (like pictures) to the Heroku server. Until now! You can use the Typus Rails backend plugin along with rails-ckeditor plugin for a rich text editor and the Paperclip plugin to pass photos/files from the ckeditor through to Amazon S3. The hosting of ckeditor images/files off Heroku at S3 was the missing component for me using Heroku for most of my client's projects. Typus is not required; but its an excellent instant admin or backend to a Rails app.
How to do it
For Typus, follow their github instructions. Once Typus is installed, you modify fields in /config/typus/application.yml. To activate a field for the ckeditor (rich text editor), copy the options/rich text code into the model.
Page: fields: list: name, title form: title, body show: id, title, body options: rich_text: body search: name application: ContentTo turn on the rich text editor, run rake typus:ckeditor in the terminal. The default rich text editor is the "Basic" one, but you'll need the "Easy" or "Full" toolbar to upload images into text areas. To change this, search for _rich_text.html.erb; and edit it to say:
Now the hard part
The hard part is getting all the uploaded images/files to be passed "into the cloud"--over to Amazon S3. If you have never used Paperclip to store images/files on Amazon S3 in Rails, stop now to experiment with that. It will be a great investment and I'm sure you'll use it in a future project. If you already have Paperclip setup to save attachments to Amazon S3, you are ready to continue. The authoritative reference is the rails-ckeditor readme at github.
My summary of the steps
- script/generate model Asset
- Copy the CreateAsset migration files from the /vendor/plugins/rails-ckeditor/examples/migrations folder and overwrite the migration waiting to happen in db/migrate
- Run rake db:migrate
- Copy the entire code from vendor/plugins/rails-ckeditor/examples/models/paperclip/models/asset.rb to your app/models/asset.rb file.
- Paste the example files from vendor/plugins/rails-ckeditor/examples/s3 folder for picture.rb and attachment_file.rb into your apps/model folder
- (Note picture.rb and attachment_file.rb are inheriting from asset.rb--that's important)
-
I had to modify picture.rb to tell it 1) where my amazon_s3.yml file was, 2) to elimate the :bucket option (because it's specified in my yml file), 3) I liked this path below better than the example.My modified picture.rb section:
has_attached_file :data, :s3_credentials => "#{Rails.root}/config/amazon_s3.yml", :storage => :s3, :path => ":class/:style/:id/:basename.:extension", :styles => { :content => '575>', :thumb => '100x100' } - Do the same this you did for picture.rb for attachment_file.rb
Done!
Ok, try script/server and see if its good! Problems, corrections in the comments. Also, you can use ckeditor in your front end, just see the rails-ckeditor readme.
-
Amish beard day at the office
15 March 2010
Today is Amish day at the office. Men are encouraged to wear their beards "Amish style" (no mustache).
-
Aardvark.com: impressive startup using Ruby on Rails
14 March 2010
I just read about this startup: Aardvark. I think it searches questions you ask through social networks to identify a likely expert, and then gets a answer/reply for you. Anyway started in late 2007. Sold to Google for $50 million in Feb 2010. Built in Ruby on Rails and their job posts show they are still hiring Rails programmers.Why Rails is appealing to startup web services
A startup can go from idea to professional web-service very quickly in Ruby on Rails. Changes can be added daily as the service grows because the code is so maintainable. When traffic comes, Rails can be optimized to handle millions of hits.
-
Book review: Refactoring Ruby Edition
13 March 2010
Refactoring is re-writing computer code so that it does the exact same thing (externally) but internally is improved. By analogy, if you simplified your shopping list so that you were getting the exact same items, but in 3 stops instead of 5--you "refactored" it. Same results; better methods. Refactoring is what you do with your code that works, so that it becomes shorter, more elegant, and useful for the next task.What is this book?
It's a classic of programming, Refactoring, written 10 years ago by Martin Fowler but adapted for the Ruby programming language.
What I loved about it
Half theory
The theory section explains what is refactoring, when to do it, why do it. Here's an example on when to refactor:
Here’s a guideline Don Roberts gave me: The first time you do something, you just do it. The second time you do something similar, you wince at the duplication, but you do the duplicate thing anyway. The third time you do something similar, you refactor.
Half examples
Half the book is 80? step-by-step examples of refactoring situations with names like "replace object with hash" and "push down method". It's like a sharp sword to be wielded in doing battle with complex software projects.
Reading good code
Reading a book with great code all over the place makes me a better programmer.
Conclusion
It's a great book; on a short list of Best Ruby Books.
-
Making the most of "unrighteous wealth"
02 March 2010
It seems that the US government has hit a turning point where its never going to have a balanced budget again. Obama says it won't happen in the next decade, and after the next decade Medicare costs, interest on the debt and Social Security costs will take off too fast for economic growth ever catch up. That forebodes a terrible economic storm as the trust in the US to repay its loans drops, the interest rate on the growing debt rises, and the US is forced to print money like a third-world country to pay its debtors. That brings to mind one of the strangest (to my ears) parables of Jesus--the dishonest manager. In it a guy is about to lose his jobs, and right before he is finally fired he conspires to write down debts of his bosses debtors--and is commended for it. Jesus concludes, "And I tell you, make friends for yourselves by means of unrighteous wealth, so that when it fails they may receive you into the eternal dwellings."
Our application: dollars (and all assets really) are going to becoming increasingly devalued. Take your money now and spend it for God. Get it out of your savings/college fund/retirement account and trade pieces of paper with Presidents on them for something that will count for eternity. Any ideas? Put them in the comments!
-
US receives German homeschooler refugees
02 March 2010
...facing fines eventually totaling over $11,000, threats that they would lose custody of their children and, one morning, a visit by the police, who took the children to school in a police van
http://www.nytimes.com/2010/03/01/us/01homeschool.html?em A federal judge in Memphis has just granted political asylum to a Christian homeschool family from Germany. I am so glad they could come here and America welcome them. Is not raising your children without threat of state seizure a clear and precious freedom? But the times are a changing. I may live to see America outlaw homeschooling with force in my generation. It may never happen. But Germany seems about 50-100 years ahead of America in it's attitude towards Christians.
-
Nashville Ruby Developers/Agencies
19 February 2010
Who are the Ruby developers in Nashville? I don't know them all, but here is an informal listing:- OG Consulting - has most Ruby and Rails experience in town
- Pixelgrazer - My top recommendation outside myself. Professional, experienced, long client list.
- Cogwise - Ruby/PHP agency looking to expand its Nashville client base
- Daniel Nelson - developer and friend from meetup group
- Brian Dailey - talented developer looking to take on more Ruby projects; friend from meetup group.
- Josh Crews - Are you in Nashville? Let me help you! Are you a Christian ministry? Call me.
-
Chanhassen, 7 weeks
09 February 2010
Look at this happy baby!
-
New project: niceSERVE
04 February 2010
I worked on a great project under Pixelgrazer (www.pixelgrazer.com) called niceSERVE.
niceSERVE is a bimonthly/quarterly mass volunteer project started in Orlando by Summit Church. On selected Saturdays the church volunteers at lots of different opportunities across their city. This app turned browsing and sign-up for the different projects into a web/iPhone form, and sends all the right notices to the volunteers, coordinators and project hosts to pull off the event. I love working on the project, loved working with Jeremy at Pixelgrazer and Daniel at Big Guns Design.
A photo of the signup kiosks in the church foyer

(I didn't do any of the iPhone stuff or the design, that was Daniel and Jeremy and the rest of the team). Hopefully the app will facilitate the expansion of the program to more organizations and more volunteers. I'm thankful I could play a part. It's cool.
-
On the essentials of software having an update to date test suite
30 January 2010
Mike Gunderloy, from his book Rails Rescue Handbook (from the sample chapter on Tests)
emphasis mine.5. Testing Rescues
There are two possible situations when you look at the tests in an application that’s come to you for rescue: 1. There are no tests 2. There are bad tests Oh, I suppose it’s possible that some day there will be an application that needs to be rehabilitated despite having an excellent and up-to-date test suite - but I’ve never seen it. More typically, there are no tests at all, or tests that haven’t been maintained and that are falling into disarray.What this means
If you ever want to add something to your application, you need to keep a test-suite written and running as you go. Tested apps don't end up in the hospital. Tested apps last and last and last. If an untested app lasts, it lasts only through many tears and weeping.

615-852-6559












