Ruby On Rails

Apparently in Rails you need to manually set the MIME-Type of attachments, otherwise their filesize, filetype and other Metadata are not properly recognized by the E-Mail client and images will not be displayed within the html e-mail.
In this case using the hash :mime_type and the corresponding value 'image/png' in the rails controller solved this problem:

attachments.inline["img.png"] = {:data => File.read('img.png'), :mime_type => 'image/png'}

Technology:

A couple of gems for RoR development

Ruby on Rails (RoR) is a trendy, rather new software framework on the brink of usefulness for professional development. The modular character of this framework allows users to easily contribute software packages in the form of Ruby Gems, which provide invaluable help with the professional deployment of RoR-software.

The following gems are, in my experience, most valuable:

1) Gems for Development

  • Brakeman
  • Download here. Brakeman is an open source vulnerability scanner specifically designed for Ruby on Rails applications. It statically analyzes Rails application code to find security issues at any stage of development.

  • Rubocop
  • Download here. A robust Ruby code analyzer, based on the community Ruby style guide. It helps with efficiently finding code passages of possible brisance.

    2) Gems for Testing

  • RSPec
  • Download here.RSpec is testing tool for the Ruby programming language. Born under the banner of Behaviour-Driven Development, it is designed to make Test-Driven Development a productive and enjoyable experience.

  • Factory Girl
  • Download here. A library for efficiently setting up Ruby objects as test data.

  • Faker
  • Download here. Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc.

  • Guard-Rspec
  • Download here. Guard is a command line tool to easily handle events on file system modifications. Helps with systematically testing RoR code.

  • Simplecov
  • Download here. Code coverage for Ruby 1.9+ with a powerful configuration library and automatic merging of coverage across test suites. It helps with determining how much of your code is covered by tests.

    3) Gems for Deployment

  • capistrano
  • Download here. A remote server automation and deployment tool written in Ruby.

Which gems are great for Ruby-on-Rails (RoR) development?

What user-contributed software ("gems") helps professionalize RoR?

Photoupload in a Ruby on Rails application

A lot of Ruby on Rails web applications have to use photos (e.g. for user profiles) In the best case these photos can be already stored in several sizes or otherwise processed before being stored to different possible location. Also these photos have to be attache to a ruby on rails model like an user or an article.

Deploying a Ruby on Rails application to the heroku cloud

Preconditions:

  • Git Repository
  • Setup Git version control for Ruby on Rails project

1. Step: Sign up for heroku

The very first step is to sign up for an heroku account. Heroku provides on free web instance which should be enough for most production needs.

Signing up can be done here: https://api.heroku.com/signup/devcenter

Step 2: Install the Heroku Toolbelt

The next step is to install the heroku toolbelt. It provides a lot of different command line commands which can be used to interact with heroku including:

  • Deploying a application to heroku
  • Configuring custom domains
  • Configuring database backups
  • Starting instances

The toolbelt can be downloaded here: https://toolbelt.heroku.com/

Step 3: First login

The next step is to do a first login using the heroku login command on the command line. If no ssl key was provided it is possible to create one now.

Step 4: Create the app on Heroku

The next step is to create an application on heroku. This application already includes one free web instance.
The task can be accomplished by running the toolbelt command heroku create on the commant line.

Step 5: Deploy
The last step is to actually deploy the application which can be done by running the command git push heroku master.

Taggings:

Deploying a Ruby on Rails application to the heroku cloud

Once a developer has deployed a Ruby on Rails application to the version control git he might want to know how to use this application in production. One solution is to use a cloud service provider like heroku and to deploy the application there.

solutions for background processing

the easiest way imho is ti use the spawn plugin.
download from: http://rubyforge.org/frs/?group_id=4646

usage is dead simple. just wrap the code to run in the background around 'spawn' like this:

spawn do
# code to run in background
end

more advanced solutions with full scale scheduling etc... might be using:
rufus-scheduler: http://rufus.rubyforge.org/rufus-scheduler/
backgroundRb: http://backgroundrb.rubyforge.org/

Taggings:

pdf:writer

use pdf:writer gem:
http://ruby-pdf.rubyforge.org/pdf-writer/

usage:
pdf = PDF::Writer.new
pdf.select_font "Times-Roman"
pdf.text "Halli hallo!", :font_size => 72, :justification => :center
pdf.save_as("hello.pdf")

Classifier gem

use the classifier gem from
http://classifier.rubyforge.org/

usage:
b = Classifier::Bayes.new 'A', 'B'
b.train_A "diese worte sind eindeutig A"
b.train_B "und alles sonst B"
b.classify "alles alles" # returns B

you can train the classifier based on already tagged content.

Taggings:

bayesian classifier, rails

a small cms system written in rails in which abstract for meetings, events, discussion or stored. in addition to being able to tag the content, the system itself should able to find appropriate tags/classifications for a text based an a bayesian classifier

Pages

Subscribe to Ruby On Rails