background preloader

ROR

Facebook Twitter

Ruby Quick Reference Guide. Here is a quick reference guide for Ruby developers: What is Ruby ? Ruby is a pure object-oriented programming language. It was created in 1993 by Yukihiro Matsumoto of Japan. Ruby is a general-purpose, interpreted programming language like PERL and Python. What is IRb ? Interactive Ruby (IRb) provides a shell for experimentation. This tool comes along with Ruby installation so you have nothing to do extra to have IRb working.

Ruby Syntax: Whitespace characters such as spaces and tabs are generally ignored in Ruby code, except when they appear in strings.Ruby interprets semicolons and newline characters as the ending of a statement. Reserved words: The following list shows the reserved words in Ruby. Here Docs in Ruby: Here are different examples: #! Ruby Data Types: Basic types are numbers, strings, ranges, arrays, and hashes. Integer Numbers in Ruby: 123 # Fixnum decimal1_6889 # Fixnum decimal with underline-5000 # Negative Fixnum0377 # octal0xee # hexadecimal0b1011011 # binary? String Literals: TravisSwicegood.com. Rails setup for V6 (multiple) · blueimp/jQuery-File-Upload Wiki. Prerequisites have jQuery setup in your appcopy jQuery File Upload files in the proper directories of your Rails app Models For use with the Carrierwave gem We'll use basic Carrierwave uploader: class AvatarUploader < CarrierWave::Uploader::Base storage :file def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" endend Let's set up a Picture model For use with the Dragonfly gem set up a Picture model (make sure you have both avatar_uid and avatar_name columns in your database) Controller First one controller to handle the downloads: (html response is for browsers using iframe sollution) And it's routes: resources :pictures, :only => [:index, :create, :destroy] Let's play In whatever view file you want, copy paste this code and enjoy.

RailsInstaller. Installing rails 4.0.0 beta. Ruby - Rails 3. Creating a production database. Get Your App Ready for Rails 4RubySource. A new Rails version is about to be released and it’s coming with many changes, deprecations, and new features. Lets take a look at what you need to do to get your app ready for Rails 4. The Path to Upgrade The easiest way to be ready for Rails 4 is having your app on Rails 3.2. If you are not in 3.2, upgrading should be done by minor versions. That is from 3.0 to 3.1, and then from 3.1 to 3.2. Deprecations Some things are going to be completely removed on Rails 4. Ruby 1.9.3+ Only Rails 4 is going to target only Ruby 1.9.3 and future versions. If you’re using Ruby 1.9.x, the upgrade should be pretty straightforward. If you’re still on Ruby 1.8.7, things could be a bit more work.

Nowadays most gems should be running on 1.9 or have a replacement. Using conditional statements in your Gemfile come in handy for having different gems on each environment until you get it all running on 1.9. It should look something like this: No More vendor/plugins Rails 4 will be removing Rails::Plugins class.

Concerns. Mkdynamic/omniauth-facebook. #360 Facebook Authentication. OmniAuth: Overview · plataformatec/devise Wiki. Since version 1.2, Devise supports integration with OmniAuth. This wiki page will cover the basics to have this integration working using an OAuth provider as example. Since version 1.5, Devise supports OmniAuth 1.0 forward which will be the version covered by this tutorial. Before you start Remember that config.omniauth adds omniauth provider middleware to your application.

This means you should not add this provider middleware again in config/initializers/omniauth.rb as they'll clash with each other and result in always-failing authentication. Facebook example The first step then is to add an OmniAuth gem to your application. Gem 'omniauth-facebook' Here we'll use Facebook as an example, but you are free to use whatever and as many OmniAuth gems as you'd like. Next up, you should add the columns "provider" and "uid" to your User model. rails g migration AddColumnsToUsers provider uid rake db:migrate require "omniauth-facebook"config.omniauth :facebook, "APP_ID", "APP_SECRET" Logout links.

Ruby on rails - undefined local variable or method `confirmed_at' for #User. Rails/sass-rails. The Lowdown on Routes in Rails 3. Today's blog post is by a guest community contributor, [Rizwan Reza]( Rizwan is an active member of the Rails community, and as of late, has been working to clean up the overgrown Lighthouse queue. We're happy to have him write for those seeking advice on deploying on a [Platform as a Service]( Stop! I'd like to tell you something important, but it may be a bit shocking, so you should probably have a seat. Here goes: everything you knew about working with routes in Rails 2... is history!

With Rails 3, you've got to roll up your sleeves, unlearn what you learned, and route the new way around. And this time, it's faster, cleaner and a lot more Ruby-like. In this post, we'll walk through the underpinnings of Routes in Rails 3. Let's start by looking at some code; here's the new DSL, in its full glory: Now check out the old way of doing it: As you can see, the example from Rails 3 is much cleaner and more Rubyish. :as. 2012 Rails Rumble.