background preloader

Ruby on Rails

Facebook Twitter

GitHub - stefankroes/ancestry: Organise ActiveRecord model into a tree structure. Tree Structures in your Rails models. What are tree structures used for?

Tree Structures in your Rails models

Tree structures are needed any time you want to insert a hierarchy into your data. It's when you want to store relationships between data of the same type, vertically. Think of categories, org charts, and family trees; all have a tree structure to them. Some examples of this are. Categories: Electronics Cameras BodiesLenses Or when working with organizational structures: Product Team IT Department Team ATeam BFinance Department Auditing 3 Types of Trees In a great article written about storing tree structures in the database, Alexey outlines 3 common patterns.

Each of these patterns have different strengths and weaknesses, especially related to whether your application is read-heavy or write-heavy. Parent-child Pros: Simple, fast writes. Parent-child tree structures are the easiest to understand, are very write-efficient, but can be extremely slow for reads, especially if your hierarchy spans more than 2 levels deep.

Now we can access our data like so: Summary. Rails Real Time Chat Application similar to Messenger - part 1 [tutorial] Setting up a Data Warehouse with AWS Redshift and Ruby – Coding@Credible. Most startups eventually need a robust solution for storing large amounts of data for analytics.

Setting up a Data Warehouse with AWS Redshift and Ruby – Coding@Credible

Perhaps you’re running a video app trying to understand user drop-off or you’re studying user behavior on your website like we do at Credible. You might start with a few tables in your primary database. Soon you may create a separate web app with a nightly cron job to sync data. Before you know it, you have more data than you can handle, jobs are taking way too long, and you’re being asked to integrate data from more sources. This is where a data warehouse comes in handy. In the past, only big companies like Amazon had data warehouses because they were expensive, hard to setup, and time-consuming to maintain.

Part I: Setting up AWS Redshift. Running Redis as a User Daemon on OSX with launchd - Ted Naleid. Learn Web Development with the Ruby on Rails Tutorial. Michael Hartl Contents Chapter 1 From zero to deploy.

Learn Web Development with the Ruby on Rails Tutorial

Setting variables on the fly · javan/whenever Wiki. If you wish to override variables in your schedule.rb file at runtime you can do so using the --set option.

Setting variables on the fly · javan/whenever Wiki

This is especially useful for changing your environment when deploying to a staging server or something similar. Example: whenever --set environment=staging. Ruby - How do I extract a sub-hash from a hash. Mike Kelley : Extract key/value pairs from a hash in ruby using an array of keys.

API Development

Javascript Integration. Social Media Integration. American Date Parsing. Wave the flag!

American Date Parsing

I recently ran into an interesting issue while working on a Rails 3, Ruby 1.9.3 project. My needs were simple: I had a single text field that allowed the user to enter a date in MM/DD/YYYY format. It was also bound to the jquery calendar plugin which was configured to prefill the textbox with the selected date in MM/DD/YYYY format. However, every time a new record was created, this date would be written as null. When I forced the date to be YYYY/MM/DD format, it would save the date just fine. If you also are fighting this issue, you can skip to the end to fix it. Problem Example Given that I have a Person: ActiveRecord::Schema.define(:version => 20120218015632) do create_table "people", :force => true do |t| t.string "name" t.date "birthdate" t.datetime "created_at" t.datetime "updated_at" end end.

#206 Action Mailer in Rails 3. Ruby script/generate scaffold < types.

Data Management

Statistical Analysis In Ruby. How I learned to test my Rails applications, Part 3: Model specs. March 19, 2012 We’ve got all the tools we need for building a solid, reliable test suite—now it’s time to put them to work.

How I learned to test my Rails applications, Part 3: Model specs

We’ll get started with the app’s core building blocks—its models. In this post, we’ll complete the following tasks: First we’ll create a model spec for an existing model—in our case, the actual Contact model. Next, we’ll simplify the process of creating and maintaining test data with factories. We’ll create our first spec files and factories for existing models by hand (though the handy RSpec generators we configured in Part 2 can be used as templates when adding future models to our application).

Anatomy of a model spec I think it’s easiest to learn testing at the model level because doing so allows you to examine and test the core building blocks of an application. To get started, a model spec should include tests for the following: #284 Active Admin. Active Admin allows you to quickly build an admin interface with just a few commands.

#284 Active Admin

Not only does it look great, but it is very customizable as shown in this episode. Download: source codeProject Files in Zip (97.3 KB)mp4Full Size H.264 Video (24 MB)m4vSmaller H.264 Video (14.9 MB)webmFull Size VP8 Video (20.4 MB)ogvFull Size Theora Video (35.1 MB) Andrey's Daily Light and Shadow. Pilu/web-app-theme. #223 Charts.