"Rails Installer: Ruby and Rails on Windows in a Single, Easy Install"

RailsInstaller is a new project from Wayne E Seguin (of RVM fame) that brings RubyInstaller-style simplicity to getting Ruby and Rails set up on Microsoft Windows (XP, Vista, or 7). In a single wizard-driven installation you get Ruby 1.8.7-p330 (with DevKit), Rails 3.0.3, Git, and SQLite 3.

Rails Installer was developed with help from Luis Lavena (a Ruby on Windows expert) and Dr. Nic Williams (Engine Yard’s resident Australian comedian) and its release comes just weeks after Wayne was (re)hired by Engine Yard to work on new open source initiatives.

To get started, go to railsinstaller.org, download the “Rails Welcome Kit” and run the installer. There’s a screencast you can watch too. The process is as simple as it sounds and you can have a basic, empty Rails project running within minutes.

If you want to follow along more, check out the @RailsInstaller Twitter account or theRails Installer Google Group / mailing list.

"Rails Installer: Ruby and Rails on Windows in a Single, Easy Install"

"Ruby, Ruby on Rails Support Discontinued in NetBeans IDE"

Dear NetBeans Community: 

After thorough consideration, we have taken the difficult step to discontinue support for Ruby and Ruby on Rails in the NetBeans IDE. Two main issues underpin this decision: 

Java SE 7 and Java Development Kit 7 (JDK 7) are the next major releases of the Java SE platform, which Oracle is committed to deliver in 2011. A key objective of the NetBeans IDE has always been to offer superior support for the Java platform. To maintain that objective and capitalize on the JDK 7 release themes–multi-language support, developer productivity and performance–it is necessary that our engineering resources are committed to a timely and quality release of NetBeans IDE 7.0. 

Second: Although our Ruby support has historically been well received, based on existing low usage trends we are unable to justify the continued allocation of resources to support the feature. 

As of January 27, the Ruby module will be gone from development builds of NetBeans IDE 7.0. Developers who want to continue to use Ruby and Ruby on Rails functionalities in the NetBeans IDE should please visit the NetBeans Ruby Support page for details on how to do so going forward. 

We remain committed to delivering a first-class product to our community of developers and users, and we encourage your feedback on our mailing lists and forums, on Twitter, or by writing to us. 

Thank you for your continued support of NetBeans.
The NetBeans Team

Source : http://netbeans.org/community/news/show/1507.html

"Ruby, Ruby on Rails Support Discontinued in NetBeans IDE"

"csrf token warning fix"

csrf token warning fix

1/ add this to your layout

<%= javascript_tag “var AUTH_TOKEN = #{form_authenticity_token.inspect};” if protect_against_forgery? %>
    <%= csrf_meta_tags %>

Add this to your controller
skip_before_filter :verify_authenticity_token

2/ comment out  protect_from_forgery from your application controller .

"csrf token warning fix"

"Rails 3, mysql and UTF-8"

So, have you started to work with rails 3? Did you realize that your UTF-8 databases doesn’t work nice with mysql? This is because the mysql gem works with ASCII-8BIT encoding, but ruby 1.9 and rails 3 works with UTF-8 encoding, so when you create a model into the database, everything works fine, but when you work with those models, it doesn’t works so nice and you don’t get what you stored.

What’s the solution? Well, there are actually three solutions, the most recommended, use mysql2, in order to do this, edit your Gemfile and include:

gem "mysql2"

and then, edit your databases.yml file, and change the adapter to mysql2

  adapter: mysql2
  database: fun_development
  user: root
  encoding: utf8

Another solution, is just instead of using the “mysql” gem, use the “ruby-mysql” gem, but it’s pretty slow because it’s a 100% ruby gem.
view plaincopy to clipboardprint?

gem "ruby-mysql"

The last solution is a monkey patch, but its also slow to use it, so I really recommend using the mysql 2 gem view plaincopy to clipboardprint?

require 'mysql'
class Mysql::Result
  def encode(value, encoding = "utf-8")
    String === value ? value.force_encoding(encoding) : value

  def each_utf8(&block)
    each_orig do |row|
      yield row.map {|col| encode(col) }
  alias each_orig each
  alias each each_utf8

  def each_hash_utf8(&block)
    each_hash_orig do |row|
      row.each {|k, v| row[k] = encode(v) }
  alias each_hash_orig each_hash
  alias each_hash each_hash_utf8
"Rails 3, mysql and UTF-8"

"Installing Ruby on Rails on Windows 7"

What is ruby on rails ?

Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for theRuby programming language. It is intended to be used with an Agile development methodology that is used by web developers for rapid development

Rails was created in 2003 by David Heinemeier Hansson and has since been extended by the Rails core team

Who is already on Rails?

  1. Yellow Pages , and many more..

Step by step instalation ruby on rails?

Before doing the installation, This is a tools You Need :

  • Ruby
  • RubyGems
  • Rails (Gem)
  • A Database Engine

Step 1: Install Ruby

  1. Download the latest stable, in this tutorial i use Ruby 1.9.2-p0 and choose 7-Zip Archives.
  2. Extract them and put all the contained directories where you want your Ruby. Mine resides in C:Ruby
  3. Add the newly installed bin directory to your path in your windows system : Open windows explorer-> right click the icon computer-> choose Properties -> in the contol panel Home, Click Advanced system settings and then click Envitonment Variables button->in the system variables click new and add new system variables like this :  Variable name : RUBY_HOME  , Variable Value : C:Ruby, after that add it in to the path and add the bin after a semicolon to the “Path” variable like this : C:Program FilesCommon FilesAdobeAGL;%JAVA_HOME%bin;%ANDROID_HOME%tools;%RUBY_HOME%bin
  4. We have to make sure that our Ruby installation was successful. So we go to our Command Prompt “Start > All Programs > Accessories > Command Prompt” and type the following:

     ruby --version

Step 2: Install Ruby Gems RubyGems is a package management framework for Ruby

  • Download Gems :  http://rubygems.org
  • Extract to C: RubyGems
  • If in Step 1 you use the installer, you can click 2x the file C: RubyGems setup.rb
  • If Step 1 uses 7z file, you can open a command prompt, then type :
 C:Rubybinruby C:RubyGemssetup.rb

if you have intalled gems, you just  upgrade to the latest RubyGems:

  gem update --system

# may need to be administrator or root

Gem ready to used .

Step 3: Install Rails

At the command prompt, type :

  gem install rails

Yups, Ruby on Rails ready for used

Step 4: Install a Database Engine

Rails is completely DB-agnostic, so we’ll describe how to install two of the more popular Database Engines: SQLite and MySQL.

How to Install SQLite

SQLite is the default database type that Rails looks for, and it’s a great, lightweight DB for Development. We’ll install SQLite3 here.

You need two files from the SQLite download page:

  • the SQLite Command Line Tool
  • the SQLite DLL

Unzip them and put the three extracted files somewhere in your path or in the rubybin directory. Now install the sqlite3-ruby gem:

   gem install sqlite3-ruby

How to Install MySQL

Download MySQL Community Server and install it. If you also do PHP programming, check out WAMP for an easy installation as well.

To use MySQL in Rails versions greater than 2.1, you’ll also need the MySQL adapter:

  gem install mysql

Because MySQL is not the default adapter, we’ll have to edit our database.yml file later.

Setup a First Project

Note: Rails 3 is now installed by default; these instructions refer to Rails 3.

Setting a Rails project is a one-line affair (from the command prompt):

  rails new myprojectname

This will build a directory, in which it will build the entire blank Rails project skeleton. To see your fresh project in action, navigate to your project root and run scriptserver:

  cd myprojectname

  rails server

Then, navigate to http://localhost:3000/ in your browser, If everything went ok you should be now looking at the Ruby on Rails: “Welcome aboard default page” :

"Installing Ruby on Rails on Windows 7"

"“Inheritance” and “Mixin Modules”"

Some object-oriented languages (notably C++) support multiple inheritance, where a class can have more than one immediate parent, inheriting functionality from each. Although powerful, this technique can be dangerous, as the inheritance hierarchy can become ambiguous.

Other languages, such as Java, support single inheritance. Here, a class can have only one immediate parent. Although cleaner (and easier to implement), single inheritance also has drawbacks—in the real world things often inherit attributes from multiple sources (a ball is both a bouncing thing and aspherical thing, for example). Ruby offers an interesting and powerful compromise, giving you the simplicity of single inheritance and the power of multiple inheritance. A Ruby class can have only one direct parent, and so Ruby is a single-inheritance language. However, Ruby classes can include the functionality of any number of mixins (a mixin is like a partial class definition). This provides a controlled multiple-inheritance-like capability with none of the drawbacks.

When a class includes a module, that module’s instance methods become available as instance methods of the class. It’s almost as if the module becomes a superclass of the class that uses it. Not surprisingly, that’s about how it works. When you include a module, Ruby creates an anonymous proxy class that references that module, and inserts that proxy as the direct superclass of the class that did the including. The proxy class contains references to the instance variables and methods of the module. This is important: the same module may be included in many different classes, and will appear in many different inheritance chains. However, thanks to the proxy class, there is still only one underlying module: change a method definition in that module, and it will change in all classes that include that module, both past and future.

<table class=codebox border=0 cellspacing=0 cellpadding=3 width=500><tbody><tr><td colspan=3 valign=top>module SillyModule</td>
</tr><tr><td colspan=3 valign=top>  def hello</td>
</tr><tr><td colspan=3 valign=top>    "Hello."</td>
</tr><tr><td colspan=3 valign=top>  end</td>
</tr><tr><td colspan=3 valign=top>end</td>
</tr><tr><td colspan=3 valign=top>class SillyClass</td>
</tr><tr><td colspan=3 valign=top>  include SillyModule</td>
</tr><tr><td colspan=3 valign=top>end</td>
</tr><tr><td colspan=3 valign=top>s = SillyClass.new</td>
</tr><tr><td valign=top>s.hello</td>
<td valign=top>»</td>
<td valign=top>"Hello."</td>
</tr></tbody></table><table class=codebox border=0 cellspacing=0 cellpadding=3 width=500><tbody><tr><td colspan=3 valign=top>module SillyModule</td>
</tr><tr><td colspan=3 valign=top>  def hello</td>
</tr><tr><td colspan=3 valign=top>    "Hi, there!"</td>
</tr><tr><td colspan=3 valign=top>  end</td>
</tr><tr><td colspan=3 valign=top>end</td>
</tr><tr><td valign=top>s.hello</td>
<td valign=top>»</td>
<td valign=top>"Hi, there!"</td>

. If multiple modules are included, they are added to the chain in order.

If a module itself includes other modules, a chain of proxy classes will be added to any class that includes that module, one proxy for each module that is directly or indirectly included.

"“Inheritance” and “Mixin Modules”"