Tuesday, April 24, 2012

10 Things you didn't know Rails could do - James Edward Gray II

10 42 Things you didn't know Rails could do
4.2 times more awesome than originally planned.

There's going to be a Rails Core panel at 5:30 today, which wasn't on the schedule initially.  That will be interesting, especially since it happens to overlap with the previous scheduled 'dinner' block.  Given the two options...I'll take the Rails Core option.

This is all for Rails 3.2 or higher


Interfaces - ways to give Rails a hug
1. Run a complete Rails app from a Single File
2. TODO, FIXME, OPTIMIZE comments -- there's a rake task to list all of those out: rake notes:todo
3. Sandbox Your Console: rails c --sandbox
4. Run Helper Methods in the Console: helper.number_to_currency(100)
5. Use non-WEBricker server in development
6. Allow you to Tap Into its Configuration: plugins can be configured the same way as the Rails app

Databases
7. Understand Shorthand Migrations on command line: can leave off types, add limits
8. Add Indexes to Migrations on command line
9. Add Associations to a Migration
10. Show you the Status of the Database: rake db:migrate:status
11. Import Your CSV Data
12. Store CSV in your Database:
13. "Pluck" Fields out of your Database - User.pluck(:email), User.uniq.pluck(:email)
14. Count Records in Groups: Event.group(:trigger).count
15. Allow you to override associations:
16. Instantiate Records Without a Database (Somewhere between cool and evil)
17. Use Limitless Strings in PostgreSQL:
18. Use Full Text Search in PostgreSQL: The reason we should all be use Postgres now instead of MySQL. 
19. Use Different Database for each user: in the case where Users will only ever be manipulating their own data.  Could potentially scale very nicely since you don't have just one database that keeps growing, and more than one database 'pipeline' for data to come through.

Ruby Extensions - Updating Ruby's fashion sense
20. Write File Atomically: File.atomic_write()
21. Merge Nested Hashes: .deep_merge FTW
22. Remove Specific Keys From a Hash: params.except(:controller)
23. Add Defaults to Hash: defaults.reverse_merge(params)
24. Answer Questions About Strings: `inquiry` magic

Views - it's all about how we look
25. Hide Comments from your Users (comments in ERB)
26. Understand a Shorter ERB syntax: ERB starts with just a single % at the beginning of the line
27. Use Blocks to Avoid Assignments in Views: assignments in views just looks bad
28. Generate Multiple Tags at Once:
29. Render Any Object: Rails used to ask the Class what partial to render, not it asks the actual Object. 
30. Group Menu Entries: select_tag(:grouped_menu...)
31. Build Forms the way you like them: Build forms the way you want them
32. Inspire Theme Songs about your work: check out @tenderlove 's themesong
33. Route Exceptions to any Rack application
34. Route to Sinatra (you can mount any Rack application in the routes file now)
35. Stream CSV to Users: Make sure to use find_each instead of all, or you've defeated the purpose
36. Do Some Work in the Background: require "thread"
37. Publish a Status Site Using Rails: page cache EVERYTHING, and then just rsync it around.


The full slide deck will be available at: http://speakerdeck.com/u/jeg2

No comments:

Post a Comment