Hi, this blog is no longer maintained, my new blog is here

Ruby On Rails and a Conning Israeli entrepreneur

Showing posts with label ruby on rails. Show all posts
Showing posts with label ruby on rails. Show all posts

Update: Social Network Ruby on Rails Applications


Update 28/1/09 : Added El-Dorado

Update 27/1/09 : Added OneBody
Update 12/2/09: Added EchoWaves, OpenMind and Forulio

One of my current consulting positions, involves a startup company with a great idea and a great social network implementation idea.
For that matter, i have been scavenging the web lately for Rails based social netowrking plugins, Engines or maybe even a skeleton application for those guys and i found some very good solution apps and infrastructures, the only problem rails Rails 2.0 compatibility (which i didn't check yet, and some don't indicate) and Documentation, which seem to be neglected on almost all those apps.

So, Here's the current list:

LovdByLess
include blogs, user profiles, photo uploads, forums, friendships and user-to-user messaging funcionallity.
Looks great and has a great look and feel.
Comes as a full application under MIT license.


CommunityEngine
A Rails engine, now supports Rails 2.0.
Gives you the basic functionality for a social networking site. It includes features such as User pages, forums, uploads, geo searches, blogging and more.
Important to say that extending the basic engine with your own controllers and models, is supposed to be easy and simple, i am currently testing it out so i don't really have an opinion yet.
Documentation has to be improved though, a lot.

TOG, presentation
TOG is basically a package of features (in the form of plugins) which you can choose to add to your applications as one, or as a whole.
Using these prepackaged and automated features should let you focus on the real key point about social networks: keep the conversation going with your members. If you’re just starting a social site or wants to polish your community with lovely social capabilities maybe you should give tog a try.

Insoshi
Features include:
  • Activity feed
  • Personal profiles with photo upload and comment walls
  • Internal messaging system with read/replied/trashed messages
  • Contacts list
  • Blogs with comments
  • Discussion forum
  • Search for profiles, forums, and blogs
  • Admin panel with site preferences
  • Option for email verification and activity notifications
Documentation is kind of missing here too.

LuvFoo
Under developement, but runs several sites at the moment,
include some neat features on top of the plain simple ones, such as API and CMS intergration.


OneBody
Although i am not sure why they indicate their audience as Churches (?), it looks like a good social framework with a lot of features such as:
  • Membership Management | aka ChMS
  • Online Directory | search, print
  • Groups | email lists, attendance tracking
  • Social Networking | friends, favorites
  • Content Management System | page editing
and more, read on in the Wiki manual


El-Dorado
Looks nice and packed, a pretty live demo site too.
Features include:
  • Forum
  • Group chat
  • Event calendar
  • File sharing
  • Random headers
  • Avatars
  • Themes
  • Privacy settings

EchoWaves

EchoWaves
This is a group chat social network application. You can start conversations and connect wih other users while discussing it.
It is possible to make a conversation read-only for presenting a content too.

Openmind

Openmind
Openmind enables you to create a collaborative environment for collecting the thoughts of your customers/collagues on a product/service.
User can discuss online about an idea & vote for the features. Admin can mark the most-requested features as "to be included in next releases" & users get informed from this. A nice application for creating a constructive community.

Forulio

Forulio: Ruby on Rails Forum
Forulio is a Ruby on Rails forum application with a similar approach to popular forum softwares like phpBB or vBulletin.
It supports sub-forums, has a monitoring page for viewing the activity and has tagging integrated.

Other resources:

Rails 2 i18n: Globalize2 plugin for Rails

A while ago i posted a post about a Globalize plugin bug in Rails 2.x. Eventually i found a solution but i was still waiting for a real solution for Rails 2.x to supersede my monkey patching.

Well, it's here.


note for the Hebrew natives: check out the examples :)



Globalize2 is the successor of Globalize for Rails.

It is compatible with and builds on the new I18n api in Ruby on Rails. and adds model translations as well as a bunch of other useful features, such as Locale fallbacks (RFC4647 compliant) and automatic loading of Locale data from defined directory/file locations.

Globalize2 is much more lightweight and modular than its predecessor was. Content translations in Globalize2 use default ActiveRecord features and do not limit any functionality any more.

All features and tools in Globalize2 are implemented in the most unobstrusive and loosely-coupled way possible, so you can pick whatever features or tools you need for your application and combine them with other tools from other libraries or plugins.


Get it from joshmh Github Repo

Rails and Amazon EC2 - Beginners guide

First of all, Amazon AWS rocks. it's a great, stable and not so expensive way to get your application up and running, but also ready for any disaster to come (Someone said Digg effect?).
Getting your application on to Amazon EC2 is not as complicated as you think, managing and controlling your instances may require a professional system administrator, but i would recommend that anyway (except if you go and host your application on EngineYard than you are worry-free, but you'll pay.. ohh you'll pay for that sense of security).

Get your application Ready

There is no real need to setup your EC2 instances in day 1, you can wait until the application is mature enough to be deployed onto a production infrastructure. Amazon EC2 costs per usage, so, it will cost you to have your application up and running on EC2, keep that in mind (although the prices are a joke).

Setting things up
Once your application is ready to be deployed to EC2, you'll need an image.
Image, in EC2 terms, is a reference to an OS + all required installations and configuration needed to run your application.
The best all-round image to use with rails is Pawl Dowman's Rails on EC2 bundle (or here). EC2onRails is great. Unfortunately, if you’ve never used EC2 before, you probably won’t be able to “Deploy a Ruby on Rails app on EC2 in Five Minutes” as the documentation claims, so this document will try to fill in the gaps for someone who has never worked with EC2.

note: it's never too early to sit down and read Amazon's documentations, they are not that bad


Local machine
First thing is first, your development machine, the one from which you will be deploying to EC2 should undoubtably hold:

  • Ruby on Rails (do yourself a favor, at least version 2.1)
  • MySQL (Well, we are going to work with RailsonEC2, which includes it, if you need another db.. you'll need another image).
  • Java Development Kit 1.5 or later installed.
    Mac users should be ready-to-go (Hah! Hah!), Windows/Linux users if you don’t have it, download it from Sun's website.
    Make sure to download a version labeled “JDK”.
    Java is required for the tools that Amazon provides to manage EC2 instances. (rumor says that there are ruby management tools also, but i prefer the ones that Amazon gives).
Signing up for the services
Once you are set with these issues, you'll need to sign up for the Amazon EC2 service, do that right here.
Now, sign up for the S3 service.
Why? becaous althougn your image (later: 'instance') includes storage, images/instances can be brought down, up, dropped and even deleted, that will ultimatly, kill your data.

S3 is Amazon’s “Simple Storage Service”. S3 is a super-inexpensive service to store files into “buckets in the cloud”. S3 will be used for database backups of your Rails Application.
Sign up for S3 here.

What you'll need to keep somewhere
After signing up, you will need to collect four pieces of information from your AWS account by visiting the Access Identifiers page.
  • Your account number. The account number can be found at the upper right of the Access Idenfiers page and should be three four-digit numbers separated by dashes.
  • Your Access Key ID. This is a 20 or so character key found in a beige box a little below your account number.
  • Your Secret Access Key. This is a 40 or so character key found in another beige box just below your Access Key ID. If this is your first time on this page, you may have to generate your key. Click the “Show” button to display your 40 character key.
  • Your X.509 Certificate Create and download the X.509 certificate below the Secret Access Key section. Place the public and private keys into a folder called “.ec2″ in your home directory.
double check it! it's very very very very important.

Download and Install the EC2 Command Line Tools

The EC2 command-line tools are a Java-based set of tools that allow you to create and manage machine instances on EC2.

Download the Command Line Tools
Download here Amazon EC2 Command-Line Tools and extract the zip file, remember where you put it, i always keep it in my home folder as a hidden folder named .ec2 (/Users/eizesus/.ec2/ on OSX).



Set Appropriate Environment Variables
export EC2_PRIVATE_KEY=/Users/eizesus/.ec2/pk-5xxxxxxxx7.pem
export EC2_CERT=/Users/eizesus/.ec2/cert-5xxxxxxxxxxxxx7.pem
export EC2_HOME=/Applications/java/ec2-api-tools-1.3-24159
export PATH=$EC2_HOME/bin:$PATH
Remember to replace my library with yours.

I suggest adding these lines to your startup profile, whatever it maybe on your OS. (OSX, it's in /etc/profile).
After you do that, reload your session (close the console/command line and open it again).

Create a Key Pair the Deployment machine


ec2-add-keypair my-secret-code
The string my-secret-code can and should be anything that you like, try to pick something that makes sense for your setup (remember that i will keep on writing my-secret-code, use your phrase instead).

Save the output from that into a file named id_rsa-my-secert-code and paste everything between (and including) the “—–BEGIN RSA PRIVATE KEY—–” and “—–END RSA PRIVATE KEY—–” lines into it. Confirm that the file contents looks exactly like this, then save the file into the file:
~/.ssh/id_rsa-my-secret-code

Set permissions on the new key file:
chmod 600 ~/.ssh/id_rsa-my-secret-code

Start Up an Amazon EC2 Instance

An Amazon Machine Image (AMI) is a named configuration of an EC2 image.
The current AMI id’s for EC2onRails are:
  • ami-c9bc58a0 (32-bit)
  • ami-cbbc58a2 (64-bit)
Start up an instance of the 32-bit EC2onRails image:

ec2-run-instances ami-c9bc58a0 -k my-secret-code
The second line of the results returned will look like:
INSTANCE        i-XXXXXXXX      ami-c9bc58a0                    pending my-secret-code       0
The pending my-secret-code means that the image is pending.
To check the status of the instance build type:

ec2-describe-instances i-XXXXXXXX
Replace the i-XXXXXXXX above with the string that comes after INSTANCE in the second line of the results from the ec2-run-instances command.
Run it again until it says running my-secret-code, than you have an Amazon EC2 instance running! (yippie!).
Take note of the string that looks like
ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com
that is your machine’s address.

Authorize SSH and HTTP

ec2-authorize default -p 22
should result in:
PERMISSION default ALLOWS tcp 22 22 FROM CIDR 0.0.0.0/0
ec2-authorize default -p 80
This should return something like:
PERMISSION default ALLOWS tcp 80 80 FROM CIDR 0.0.0.0/0
you are up and ready to go!
You should be able to ssh into the your new machine, replace
ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com
with your own machine’s address:
ssh -i ~/.ssh/id_rsa-ec2-rails-keypair root@ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com
You may have to type “yes” to accept the authenticity of the host.

Prepare Your Application for EC2

EC2 for Rails requires Capistrano:
sudo gem install capistrano -v 2.4.3
And then install the EC2 for Rails gem:
sudo gem install ec2onrails
Okay, you need to add three configuration files to your Rails application.
  1. Capfile - save this file at the root of your application.
  2. deploy.rb - save this file in the /config folder.
  3. s3.yml - also save this file in the /config folder.

Customize the EC2 Configurations
capfile can an be left as-downloaded.
config/s3.yml - This configuration is pretty simple, under the production section, put your AWS information that you noted above.

  aws_access_key: (you got me when you signed up)
  aws_secret_access_key: (me too)

  bucket_base_name: production.yourname.com
config/deploy.rb - There are a lot of definitions to be made, read all the comments and setup the deploy process as your applicaiton requires.

config/database.yml - For the production section, basically add any good password that you like and add hostname: db_primary. It should look something like:
production:
  adapter: mysql
  encoding: utf8
  database: appname_production
  username: user (not ROOT!)
  password: password (no, no empty passwords)
  hostname: db_primary

Run the EC2 on Rails Capistrano Tasks

cap ec2onrails:get_public_key_from_server cap ec2onrails:server:set_roles

Configure the db and stuff:

cap ec2onrails:setup
And launch your app:
cap deploy:cold
And wooooohoooo, check your application url.

That's it basically, you are up.

Looking for a RoR team

Well, it's time to move on and work on marketing my new application (can't tell you what it is yet :) ), but i need a dedicated, professional Rails+Client Side development team to support the final stage of development, and to continue supporting further changes.
I heard about people getting teams in India, and some companies offer services for out-sourcing code, but i prefer at the moment to find a team (india, USA doesn't matter) that will support my application and will be ready to put some real work into it.
anyway, if anyone is interested, post me a message on linkedin.
basically the skills i need are

* Ruby on Rails experience (2.x)
* Client side (JQuery, MooTools, MochaUi is a great plus).
* CSS and some basic design capabilities.
* DBA (MySQL, Oracle experience will be a great advantage).
* Amazon AWS+S3+EC2 experience.
* ability to work remotely.

i will prefer a whole team, rather than finding these skills in specific programmers and building the team myself.

UPDATE: All positions are filled, thank you everyone!

Using ruby on rails with Oracle Legacy.

Great slide on SlideShare.
introduces the ruby-plsql gem, which makes it easier to preform database functions and stored procedures from ruby/rails applications (and supports bind variables).
i personally wrote a module of my own to handle this need (which supports bind variables as well).
Check out the slide and pay attention to the oracle_enhanced_adapter now available.
The slide is over here at SlideShare.

Rails 2.2: Quick Feature list

Rails 2.2 was just released, and ryan strieks again with a great post.

let’s take a peek at some of the major new features (as determined by yours truly – feel free to pipe up with features that I’ve missed).

Rails 2.2.2 requires rubygems v 1.3.1, so before you upgrade make sure to do a sudo gem update --system.

Rails 2.2 Features

i am personnalt still on 2.1, and i don't think i will upgrade at this moment, but some features look very-needed in fact.

Rails Plugin: Dynamic Session Expiry

With session_lifetime you can set after how much time of inactivity your session should expire, you can execute an action when the session expires, and you can set where to redirect_to after session expiry.
Example


class ApplicationController << ActionController::Base
expires_session :time => 2.hours, :redirect_to => '/login'

protected
def on_expiry
flash[:notice] = "Your session has been expired, and you have been logged out."
end
end


Get it from

git://github.com/DefV/session_lifetime.git

Restful Web services gem

i recently read at John Nunemaker's blog about a gem he wrote for simplifying the consumption of REST web services.

Read more about the HTTParty Gem

Rails Tip: image_tag, SEO Optimization

when you use rails's image_tag, by default it sets the HTML attributes of alt and title to the filename of the image. so for

image_tag 'dscn0001.jpg'

will produce the following html something like that

<img src="images/dscn0001.jpg" alt="dscn0001" />


the alt attribute for image tag is meant to explain the content of the image in case the actual image was not found, or for non-graphic browsers.

The default value for the alt attribute should not be used, unless the file name does not really supply information about the image. my suggestion is to use the :alt option in the image_tag helper.

important: do not attempt to use the alt for keywords heaping ('elad-rails-blog-ruby.jpg'), this will not help you in your SEO.

Stand Alone ruby on rails application

Ok,
I Don't really know if anyone has ever done this before, but after viewing some unrelated posts regrading ruby and rails, i succeed in creating a stand alone ruby on rails application.
By saying stand alone, i mean you can copy your application to a usb driver, and start your mongrels anywhere you want!.

i wrote some scripts to setup what the application needs prior to loading, and got it running in no time.

i succeeded doing this with rails 1.2.6 so far, but i don't see any reason why i should not do it with 2.0/1.

now my offer goes a little of something like this, if you will come up with an idea how to make me (and you :) ) some money with this new trick, i'll give up 45%.

start thinking :)

Ruby On Rails Developer Salary in the US


the graph is right here


Data Provided by of simplyhired.com, a search engine for jobs.

As i can see, $86,000 per year, that makes it about $7,100 USD a month, which is just a little more than what a super-rails ninja can get here in Israel, probably more for a short period projects.

how come?

Dump a Model table to fixtures

 


def self.to_fixture
write_file(File.expand_path("test/fixtures/#{table_name}.yml", RAILS_ROOT),
self.find(:all).inject("---\n") { |s, record|
self.columns.inject(s+"#{record.id}:\n") { |s, c|
s+" #{{c.name => record.attributes[c.name]}.to_yaml[5..-1]}\n" }
})
end

.not proxy for ruby

a post in Powdered Non Sequitur Man made it possible.
".not" proxy for ruby
so no more

!cond

but,

object.attribute.not.nil?

New Design For Pdfetch.com


New design for Pdfetch.com is up, thanks to Barak Edry who did everything to make it look better.
thanks man!

PDFetch released

PDFetch.com was released today by me and Shmuel Ahdut.
PDFetch is a simple app to enable a phrase specific search of online (and free of course) PDF files (other file types will be supported later on).
i will appreciate comments and remarks.

Model Reflection Overview

We all use ActiveRecord Reflection on the fly while programming, since we declare all the relations in the model and we are considering it as obvious.
i tried to search and see if there is a way to find those reflections and to alter it in runtime.

Model.reflections


i found this collection which contains all the information about the current model reflections.
for example.

  • .macro: this will return the type of the current reflection (:has_many, etc..)

  • .primary_key_name: the reflection primary key

  • .options: the reflection SQL join options

  • etc. etc.



for example, the following code will show me all the reflections for a model named Article:

  1. >> y Article.reflections.values.collect {|e| e.macro.to_s  + " => " + e.primary_key_name.to_s }  
  2. ---   
  3. - has_many => taggee_id  
  4. - belongs_to => layout_id  
  5. - has_many => article_id  
  6. - has_one => subject_id  
  7. - belongs_to => user_id  
  8. - has_many => taggee_id  
  9. => nil  

iphone on rails

A simple way to build iPhone specific interface with Rails

  1. class ApplicationController < ActionController::Base  
  2.   exempt_from_layout('iphone_html.erb')  
  3.     
  4.   before_filter :check_iphone  
  5.     
  6.   protected  
  7.   def iphone?  
  8.     request.user_agent.include?('iPhone')  
  9.   end  
  10.     
  11.   def check_iphone  
  12.     if iphone?  
  13.       request.parameters[:format] = 'iphone_html'  
  14.     end  
  15.   end  
  16. end  
  17.   
  18. class DashboardController < ApplicationController  
  19.   def index  
  20.     @top_movies = Movie.top_movies  
  21.     @movie = @top_movies.first  
  22.       
  23.     respond_to do |format|  
  24.       format.html # index.html.erb  
  25.       format.iphone_html #index.iphone_html.erb  
  26.     end  
  27.   end  
  28. end  

The running program

sometimes it can come handy to be able to know in which program you are running know.
it can be useful when displaying error information or such.

  1. caller(0)[0].split(".rb")[0]  >>  "(irb):74:in `irb_binding'"  

Setting up logger options


i was called the other day about one of my past projects server going down because it's production log exceeded 2GB.
regularly, there is a cron job to cycle the log file and prevent such joyous occasions, but for some reason it didn't happen. so i decided to read a little bit about the Logger class in Rails and see if it has some magic for me yet.



in order to replace the log file path (and/or name) use the following syntax in environment.rb:

  1. Rails::Initializer.run do |config|  
  2.   config.logger = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log")  
  3. end  


The actual cure for my problem came when i found the option to prevent the logger file from exceeding a pre-defined limit.
  1. config.logger = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log", 1, 2*1024*1024)  


and a little extra for creating a brand new log file for each day.
  1. config.logger = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log""daily")  


i suggest reading even more on the rails development browser

Unique Insertion into Array


  1. [1,2,3] | [3,4,5]       >> [1, 2, 3, 4, 5]  


The Web Ask eizesus.com

Subscribe

    follow me on Twitter

    Twiters Around

    About Me

    My photo
    I am a web developer for more than 9 years, managed, cried, coded, designed and made money in this industry. now trying to do it again.

    Labels