header image

Archive for May, 2006

Cheap zoloft

Wednesday, May 31st, 2006

Just two weeks after Ruby on Rails was featured in the prominent Dr Dobb’s Journal, cheap zoloft, it gets into the limelight again, cheap zoloft, in even greater power than before: Guess who is staring at you from the frontpage of Linux Journal? Yes, cheap zoloft, it’s DHH… Cheap zoloft, and the reason? The current issue is full of Ruby and Rails articles, cheap zoloft, tips and tricks etc. Cheap zoloft, Read the full story at David’s blog.

Similar Posts:soma sale,cheap zoloft,buy generic xanax,cialis in malaysia,phentermine sale

Viagra sale

Wednesday, May 24th, 2006

I have announced the upcoming release of the W3C Mozilla DOM Connector in one if my previous posts, viagra sale, and now it has finally arrived. Viagra sale, You can view it at

http://svn.rubyrailways.com/W3CConnector/

or check it out with svn:

svn co http://svn.rubyrailways.com/W3CConnector/

For a description about the connector, viagra sale, please refer to my previous post. Viagra sale, If you would like to try it out, viagra sale, here is how:

#this code snippet gives you a DOM document of the currently loaded page:
  nsIWebBrowser brow = getWebBrowser();
  nsIWebNavigation nav =
      (nsIWebNavigation)
      brow.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
  nsIDOMDocument doc = (nsIDOMDocument) nav.getDocument();
  Document mozDoc = (Document)
org.mozilla.dom.NodeFactory.getNodeInstance(doc);

From now on, viagra sale, you can use all the existing java/dom libraries such as an XPath2 engine like saxon, viagra sale, xalan, viagra sale, whatever you want working on mozilla documents. Viagra sale,
This means tremendous power compared to (in their category outstanding, viagra sale, but still limited) tools like RubyfulSoup or Mechanize, viagra sale, stemming from the power of XPath to query XML documents. A simple example - dumping DOM of the html document to stdout:

public static void writeDOM(Node n)
      throws IOException
  {
      try {
          StreamResult sr = new StreamResult(System.out);
          TransformerFactory trf = TransformerFactory.newInstance();
          Transformer tr = trf.newTransformer();
          tr.setOutputProperty(OutputKeys.ENCODING, viagra sale, "UTF-8");
          tr.transform(new DOMSource(n), viagra sale, sr);
      }
      catch (TransformerException e) {
          throw new IOException();
      }
   }

Cool, viagra sale, isn’t it?
At the moment, viagra sale, I am discussing different integration issues with the Mozilla guys, viagra sale, since the connector should be the part of Mozilla and the Eclipse editor in the future.

Similar Posts:soma prescription,viagra sale,order synthroid,sibutramine,cheap kamagra

Cheap phentermine

Sunday, May 21st, 2006

In my previous post on migrations i wrote that “…they are not covered in any of the basic books on RoR”. Cheap phentermine, Well, cheap phentermine, this statement does not hold anymore, cheap phentermine, since Agile Web Development with Rails, cheap phentermine, 2nd ed. is already creating the models with migrations.

While the last part of the post (why are migrations so cool) is still up-to-date, cheap phentermine, they way of creating migrations is different from 1.1 on, cheap phentermine, so i have decided to review the topic and add some new points, cheap phentermine, too.

Migrations are now created automatically with the model

In my previous post, cheap phentermine, i have been creating the migration manually with the command

ruby script/generate migration ProductMigration

However, cheap phentermine, as of Rails 1.1, cheap phentermine, you don’t have to do this anymore. Cheap phentermine, When you generate the model (let’s stick with the Product model as an example) the migration is automatically generated:

ruby script/generate model Product
...
... Cheap phentermine, #some lines omited
...
create db/migrate/001_create_products.rb

Now you can edit the file db/migrate/001createproducts.rb to contain something like this:

class ProductMigration < ActiveRecord::Migration
def self.up
create_table :products do |table|
table.column :title, cheap phentermine,       :string
table.column :description, cheap phentermine, :text
table.column :image_url, cheap phentermine,   :string end
(rest of the file omited)

Then run

rake db:migrate

To update the database. Cheap phentermine, That’s even easier than in the previous versions of rails!

Valid column data types and possible options

Valid columns are:

integer, cheap phentermine, float, cheap phentermine, datetime, cheap phentermine, date, cheap phentermine, timestamp, cheap phentermine, time, cheap phentermine, text, cheap phentermine, string, cheap phentermine, binary and boolean.

Valid column options:

  • limit ( :limit => “50” )
  • default (:default => “blah” )
  • null (:null => false implies NOT NULL)

string is the equivalent of varchar(255), cheap phentermine, so if you would like to have a string column (called title) of length 100 instead of 255, cheap phentermine, with default value ‘Some title’ and to forbid NULL value, cheap phentermine, you have to type

table.column :title, cheap phentermine,
:string, cheap phentermine,
:limit   => 100, cheap phentermine,
:default => "Some title", cheap phentermine,
:null    => false

Generating test data

I am quite sure you know the situation when you want to test something quickly and you waste precious time to generate some test data, cheap phentermine, which you trash after the testing just to find yourself in the same situation later?

Well, cheap phentermine, migrations can help you to prevent headaches because of this, cheap phentermine, too. Cheap phentermine, Here is how:

ruby script/generate migration create_test_data
Create db/migrate/002_create_test_data.rb

You can create test data inside the migration file like this:

class ProductMigration < ActiveRecord::Migration
def self.up
Product.create(:title => 'My cool book about the meaning of life', cheap phentermine,
:description => '42', cheap phentermine,
:image_url => /images/cool_book42.png)

You can now commit this migration to the RCS you are using, cheap phentermine, and modify/add more test data later.

The other advantage is that your colleagues won’t spend time writing dummy test data either: they can just check out this migration and happily use the provided tests.

If this is still not enough for you…

You can write SQL statements inside the migrations. Cheap phentermine, For example:

execute "alter table items
add constraint fk_items_products
foreign key (product_id) references products(id)"

However, cheap phentermine, use this with care since you have to write native DDL statements, cheap phentermine, which violates one of the fundamental ‘cool factors’ of migrations: independence from DB vendors.

Conclusion

The Agile Web Development with Rails, cheap phentermine, 2nd ed can be considered as the Rails bible and since it is promoting migrations as the definitive way to handle your DB issues, cheap phentermine, i think migrations will become (in fact the already did for lots of people) the state of the art. Cheap phentermine, After using them for a while and enjoying the power and flexibility they provide without having significant drawbacks, cheap phentermine, i don’t really see why should one not use them in the future.

Similar Posts:zoloft sale,cheap phentermine,xenical prescription,xanax sale,buy alprazolam

Cheap viagra

Tuesday, May 16th, 2006

I am working on a small screen-scraping utility written in Ruby, cheap viagra, and since I have been working previously with RubyfulSoup, cheap viagra, I wanted to give WWW::Mechanize a try this time.

So i have installed the WWW::mechanize gem:

sudo gem install mechanize

I wanted to try a ‘Hello world’ application first, cheap viagra, to see wheter it works. Cheap viagra, Here are some official examples (click on ‘Examples’). Cheap viagra, I Copy&pasted the first one, cheap viagra, run and got the following error:

/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require__': no such file to load -- net/https (LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
from /usr/lib/ruby/gems/1.8/gems/mechanize-0.4.4/lib/mechanize.rb:15
...
...

After some googling i have found the answer: I had to install libopenssl-ruby, cheap viagra, and the error was gone.

I wonder if you have to install this amount of additional packages on other distributions also? From the time I am using Ruby/Rails I did not have other distro than Ubuntu, cheap viagra, but back in my Python days I have been running on gentoo and I don’t remember such problems. Cheap viagra, Ubuntu is really very cool, cheap viagra, but it seems you have to know well which packages do you need and install them manually when it comes to coding/development…

Similar Posts:viagra prices,cheap viagra,buy cheap ativan,buy cheap viagra online,cheap propecia

Online viagra

Tuesday, May 16th, 2006

Every second blog I came across recently has an entry about google trends, online viagra, so I am adding my small findings too! ;-)

After playing with it for a few hours, online viagra, I have to say that writing a relevant query is not always as easy as it seems. Online viagra, People are posting Java vs Python vs Ruby comparisons, online viagra, but they are not always aware that the graph contains (among other things) the comparison of an island, online viagra, a comedy troupe (Monty Python) and a character set (Ruby Characters), online viagra, for example. Online viagra, According to wikipedia, online viagra, all three terms have more than ten possible meanings, online viagra, and although a tech nerd may know only one for each of them, online viagra, not all pages out there are (fortunately) written by tech guys.

Let’s start with some Rails related stuff:

Well, online viagra, I wonder who else recently (not even necessarily in the computer industry) got so famous in a matter of days… It is interesting that there is no data available for “David Heinemeier Hansson” or even “David Hansson”, online viagra, just for DHH.

The next graph could answer the question whether it is a good idea for a web hosting company today to support Ruby on Rails:

For the idea of the following googleTrendFight thanks for Laszlo on Rails blog.

It’s really thrilling to see that a (once) small open source community can compete with enterprise stuff of such magnitude as JBoss/EJB (ok, online viagra, this is kind of apples-to-oranges, online viagra, but nevertheless interesting). Online viagra, If you wonder why did JBoss’ search volume go dramatically up - it’s because RedHat bought the company.

Non-Rails related: slashdot.com vs digg.com vs reddit.com:

No comment…

The last one about wikipedia, online viagra, kind of funny:

Why should be this funy? Because the only point in the history (so far) when search volume for wikipedia was declining was because of:

Probably (hopefully?!?!) there is no direct link between these facts, online viagra, but it is an interesting random coincidence then…

I wonder whether google will improve the quality of this search and/or add possibility to specify advanced queries to prevent mixing in of irrelevant results - at the moment, online viagra, if I did try to narrow the search, online viagra, in lot of cases i got back ‘data not available’… Online viagra, Interesting toy, online viagra, though.

Similar Posts:buy soma,online viagra,cialis,generic ultram,buy generic cipro

Phentermine

Saturday, May 13th, 2006

I have just installed Ubuntu Dapper Drake Flight 6 on my desktop machine, phentermine, and because I had had different problems to install Rails from scratch several times (even the recent session was no exception), phentermine, I have decided to write a step-by-step guide, phentermine, which assumes a clean, phentermine, fresh install of Ubuntu ( i.e. Phentermine, at this point you do not even have Ruby on your machine) and leads you through installing Rails and creating a working test application. Why is this writeup better than any other how-to-install-rails tutorials out there?

  • Because it will tell you to install really just what you need, phentermine, not 50 packages more
  • It will also show you how to configure the DB and other things to really make Rails work, phentermine, not just installed

Let’s get started! Note: Some people asked if this manual is for dapper only. Phentermine, I would say mostly yes, phentermine, because i have had different problems on breezy (for example i had to compile ruby-mysql driver manually). Phentermine, Its not entirely impossible that it will work with breezy - but then you will have to make sure that the packages are the same version as assumed here (e.g. Phentermine, MySQL > 5 etc.)

Part I: Installation

Prepare the system for the installation

  • Check /etc/apt/sources.list - make sure you have access to the ‘universe’ packages by uncommenting them:
deb http://us.archive.ubuntu.com/ubuntu dapper universe
deb-src http://us.archive.ubuntu.com/ubuntu dapper universe
  • Refresh apt packages to make sure you get the most up-to-date stuff:
sudo apt-get update
Install Ruby related packages
  • Install Ruby essentials: ruby, phentermine, irb, phentermine, rdoc, phentermine, ri
sudo apt-get install ruby rdoc ri
  • Install gems: download, phentermine, unpack, phentermine, install
go to http://docs.rubygems.org/
download rubygems-0.8.11.tgz (or the latest version)  tar -xzvf rubygems-0.8.11.tgz
cd rubygems-0.8.11/
sudo ruby setup.rb
MySQL installation and configuration
  • Install MySQL:
sudo apt-get install mysql-server
  • Install ruby MySQL bindings
sudo apt-get install libmysql-ruby
Install Rails
sudo gem install rails --include-dependencies

Part II: Configuration

Setup the DB
  • Add an user, phentermine, create a test database and grant acces for the user
mysqladmin -u root create test_development
mysql -u root
Into the db shell, phentermine, write the following commands:
create user 'batman'@'localhost' identified by 'robin';
grant all on test_development.* to 'batman'@'localhost';
Don’t forget to replace the username/password (unless you happen to be Batman of course - in this case i suggest to use a different password since this can be guessed easily by social engineers ;-) Create and test the rails app
  • generate the app files
Lets denote your working directory (the root directory where your future rails project s will reside rails_projects).
cd rails_projects
rails test
  • edit config/database.yml
cd rails_projects/test 
vim config/database.yml
  • It should look like this:
development:
adapter: mysql
database: test_development
username: batman
password: robin
host: localhost
  • generate a dummy model
ruby script/generate model Dummy
  • edit the migration file
vim db/migrate/001_create_dummies.rb
class CreateDummies < ActiveRecord::Migration
def   self.up
  create_table :dummies do |t|
    t.column :foo, phentermine,    :string
    t.column :bar, phentermine,    :string
  end
end

def self.down
  drop_table :dummies
end
end
  • run the migration
rake db:migrate
  • generate a simple maintenance app
ruby script/generate scaffold Dummy Admin
  • start the server
ruby script/server

Point your browser to http://localhost:3000/admin to see the result. If you have any problems, phentermine, please leave a comment, phentermine, i will try to help you.

Internet contains huge number of opportunities to earn money online. Phentermine, Simply create a site that you think has the potential to sell hot items using ruby on rails. Phentermine, Register a relevant domain name and purchase a web hosting service through hostgator, phentermine, one of the better web host out there today. Phentermine, Get a internet connection through one of the wireless internet providers to upload your site. Phentermine, Work on search engine optimization to get a better traffic and also use affiliate marketing program for the same reason. Phentermine, Finally get a free voip phone service to contact customers directly. Phentermine, The pc to phone system is the most effective method of marketing.

Similar Posts:discount zoloft,phentermine,order reductil,purchase cipro online,clomid prescription

Xanax

Friday, May 12th, 2006

I am happy to announce that the much anticipated W3C Connector, xanax, after lots of coding, xanax, testing, xanax, bug fixing and several months of successful usage in a commercial product was proven worthy to be released to the public. Xanax, If everything goes well, xanax, it will hit the streets next week.

OK, xanax, but what the heck is the W3C Connector?

The W3C Connector is a Java package which can be used to access the Mozilla DOM tree from Java, xanax, while implementing the standard org.w3c.* interfaces. Xanax, This means you can use it with any standard Java package that is expecting org.w3c.* interfaces ( Xerces, xanax, Saxon, xanax, Jaxen, xanax, … Xanax, ) to execute effective queries on the Mozilla DOM (XML/XSLT/XPath/XQuery operations for example).

Technically, xanax,the W3C Connector is an implementation of the standard org.w3c.* interfaces. Xanax, The implementing classes are calling Javier Pedemonte’s JavaXPCOM package, xanax, which in turn wraps the Mozilla XPCOM in order to gain access to the Mozilla DOM. Xanax, See the image for an illustration:

This is very nice and all, xanax, but why should I care about it?

If you ever wanted to do (or have done) a screen scraping application, xanax, where you needed to understand the underlying document to some extent (regular expressions were not sufficient) you should know that there are many pitfalls along the way:

  • First of all, xanax, malformed HTML code: Despite the continuous efforts of the W3C and other organizations/individuals to remedy this problem by promoting X(HT)ML and other machine parsable formats, xanax, a lots of web pages still have malformed code in them. Xanax, Based on the level of non-standardness, xanax, parsing such a page can be more than a moderate technical problem: in practice there are pages which can not be parsed to produce an usable input.
  • You can not use a standard query language like XPath or XQuery - these languages require a XML input, xanax, which you can not ensure because of the previous point, xanax, so you are left to roll your own code to process the parsed data.

Of course this is not a big problem for a crafted programmer, xanax, mainly if he is equipped with tools like HTMLTidy to address the first point, xanax, RubyfulSoup or similar to tackle the second. Xanax, However, xanax, even these (and other) tools and a cool programming language are still just easing up the pain of effective screen scraping, xanax, but not offering a generic solution. Xanax, If you want to scrap a lot and different pages, xanax, these problems in practice will cripple your efforts (or at least make it last very long time in practice).

How does the W3C Connector solve this problem?

By solving both points: The Mozilla DOM is a structure reflecting how gecko (the mozilla rendering engine) renders the page, xanax, and it always translates to valid XML (no unclosed tags or otherwise malformed code), xanax, and because of implementing the org.w3c.* interfaces you can use very robust and effective XPath packages (like Saxon) to query the document for effective HTML extraction.

There are of course a lot of other possible uses - the connector is not a tool itself, xanax, but a gateway to the world of W3C compliant XML tools - it is up to you how to leverage the power it gives you.

The Big Brother

The W3C Connector will be released officially as the part of theATF project. Xanax, The code is under the last review at the moment, xanax, it is possible that I will come out with a preview release before the official one.

Similar Posts:cialis prescription,xanax,soma pills,lexapro no prescription,doxycycline sale

Order zoloft

Monday, May 8th, 2006

I am in the process of redesigning rubyrailways.com, order zoloft, so you can see every kind of weird experiments sometimes (I am too lazy to do the whole thing offline, order zoloft, because that would mean to set up Apache, order zoloft, PHP, order zoloft, Wordpress, order zoloft, MySQL … Order zoloft, etc, order zoloft, and the other reason is: I have too limited time to do it quick).

As you can see, order zoloft, currently I am experimenting with one of the most widespread cliché of today’s webdesign: round corners. Order zoloft, There are infinite possibilities to round your corners - as my primary focus is not web design, order zoloft, i am not really an expert on the topic, order zoloft, but i have seen a lot of methods (various ratio of (no) images, order zoloft, JS and CSS). Order zoloft, For example, order zoloft, a Firefox friendly quick’n'dirty solution:

Simple, order zoloft, but limited

(no images and JS needed, order zoloft, but has severe cross-browser restrictions - if you are reading this from IE (or probably anything other than Firefox) you know what i mean).

Browsing through the possible solutions, order zoloft, i have chosen Nifty cube. Order zoloft, It is an image-less solution, order zoloft, all you need is to add 1 line of Javascript and a few lines of CSS code to make it work. Order zoloft, It has a lot of options (this i already the second version, order zoloft, which is a substantial overhaul compared to the first one), order zoloft,

and for me it worked nicely. Order zoloft, (Have to work on the actual usage, order zoloft, though - The rounded div’s around the title are too big ATM, order zoloft, but this is not the problem of Nifty cube)

Similar Posts:order lexapro,order zoloft,zovirax prescription,cheap cipro,cialis internet

Discount zoloft

Friday, May 5th, 2006

As I wrote in my previous post, discount zoloft, I am currently reading/coding the depot example from the Agile Web Development with Rails book. Discount zoloft, I had one unclear issue so far - maybe someone can help me to find it out: I did something wrong or this is really a typo in the book?

Putting sessions in the database According to the book, discount zoloft, this should be done with

rake db:session:create

However, discount zoloft, after entering this command to the console I got:

(in /home/peter/development/src/railsprojects/depot)
rake aborted!
Don't know how to build task 'db:session:create'

After some playing with rake –help, discount zoloft, I have found the –tasks switch:

rake --tasks

and here I have finally found the remedy for my problem: the correct command is

rake db:sessions:create

(note the additional ’s’ character) Is this because my rake version is too old/too new or this is a typo in the book?

After this modification everything worked again as intended.

Similar Posts:order soma,discount zoloft,viagra pharmacy,buy cheap reductil online,xenical online

Phentermine pills

Thursday, May 4th, 2006

I have bought both books recently. Phentermine pills, Maybe it is a little bit early to write a review since I am through just a few chapters in both, phentermine pills, I have been so impressed that I had to write a (not so) short entry at least ;-)! I have been using C++/Java/Python for years, phentermine pills, and have been reading as much books on every possible aspect of development with these languages as I could get. Phentermine pills, In my oppinion Ruby and Rails are absolutely superior to all of these languages (and their web frameworks/related things) in this context - The Pickaxe, phentermine pills, AWDwR and R4R cover nearly all the things you will ever need to learn the language and Rails - and not just understand the ‘how’, phentermine pills, but also the ‘why’, phentermine pills, learn best practices, phentermine pills, coding and development methodologies from code style to design issues, phentermine pills, related technologies and more.

The point is not (only) this, phentermine pills, since you can do the same with a few Java books (although not 3, phentermine pills, but something like 10), phentermine pills, however you will have harder time with Python (There is a Django book on the way, phentermine pills, and also the Turbogears guys are publishing one but neither are out yet - but no PickAxe, phentermine pills, AFAIK) - however, phentermine pills, the point is, phentermine pills, based on the experiences i have had with C++/Java/Python books that neither of them are so well written/to the point/effectively explained/well built up than the Ruby ones. Phentermine pills, Simply put: The Ruby/Rails books are the best technical books i have ever read on programming and (web) development.

AWDwR 2nd ed Agile Web Development with Rails, phentermine pills, Second Edition I begun to develop the depot application with the first edition about a month ago, phentermine pills, and since I was new to both Ruby and Rails, phentermine pills, I have thought: WOW! I was about halfway through the depot chapter when i have noticed the announcement about the Second Edition a few days ago. Phentermine pills, I have purchased the pdf version immediately, phentermine pills, and I am quite sure this purchase has to be listed in my ‘Best value for money TOP 10′ list (along with R4R ;-). It was a very refreshing experience to code the depot application from the first edition, phentermine pills, but as I got into Rails more and more, phentermine pills, I have felt that there are some small gaps here and there. Phentermine pills, On the mailing list, phentermine pills, everybody was talking about migrations (i had no clue that time about them), phentermine pills, helpers, phentermine pills, AJAX/RJS, phentermine pills, REST and other stuff i was not able to find during the depot development, phentermine pills, and though the amount of information and level of coolness was overwhelming, phentermine pills, I still sensed there is still even more than this. After redoing the depot application with the second edition, phentermine pills, all these things (among others) are finally there! You get all the goodies from the very beginning (migrations, phentermine pills, writing your own helpers, phentermine pills, AJAX etc) so you do not have to search the Web for the newest features anymore.My overall impression was that the small annoying things are gone, phentermine pills, the good things are even better, phentermine pills, thus the overall experience of reading the book/following the code is even more delightful! I can’t wait for the next chapters! This upgrade definitely rocks! Well done Dave et al.
Ruby for Rails Ruby techniques for Rails developers I have gone through just the firs three chapters so far, phentermine pills, and though they are supposed to be introductory chapters (entitled How Ruby works, phentermine pills, How Rails works and Ruby-informed Rails development) I could not believe how much info I got out of them. Phentermine pills, I have to say that I am a totally mega-n00b to both Ruby and Rails, phentermine pills, but still, phentermine pills, I have gone through the PickAxe and half of AWDwR, phentermine pills, 1st ed, phentermine pills, i am a regular reader of Ruby-talk and the RoR mailing lists, phentermine pills, so on the other hand I have some basics, phentermine pills, and still these chapters provided me a lot of new insight. The book (or at least the first three chapters) is extremely well written, phentermine pills, easy to grasp yet the breadth of knowledge is really impressive. Phentermine pills, It really shows the design philosophy, phentermine pills, logics, phentermine pills, inner working of the things rather than just providing some theory with a few examples, phentermine pills, or being a ‘yet another Ruby/Rails book’ in any way. Phentermine pills, If you would like to find out how the things really work, phentermine pills, and why they work that way, phentermine pills, rather than just be a developer who can do this and that with Rails, phentermine pills, definitely check this book out! R4R

There was a kind of flamewar on the Ruby on Rails mailing list about the pricing of the AWDwR second edition: One group argued that they should get some discount because they own the first edition, phentermine pills, and the other party did not agree with this standpoint. Phentermine pills, Well, phentermine pills, personally I am definitely in the second group - I did not hesitate to buy the PDF for a moment - I can understand (but not support in any way) the arguments of the first group, phentermine pills, but I would gladly pay for this book even $100, phentermine pills, not $20+, phentermine pills, regardless of the editions I own. Phentermine pills, (And just FYI, phentermine pills, I am a full time Java developer and though I would like to get a Ruby (on Rails) job ASAP, phentermine pills, due to different constraints RoR is and will be just my hobby for some time)

Just my 2c.

Similar Posts:cheapest lexapro,phentermine pills,buy cheap synthroid,levitra online stores,order plavix

Cheap prozac

Wednesday, May 3rd, 2006

Although migrations are a very cool feature of Ruby on Rails, cheap prozac, they are not covered in any of the basic books on RoR i have encountered so far (Agile Web Development with Rails, cheap prozac, Ruby for Rails Programmers).

Update: Check out my recent post: Ruby on Rails Migrations: Reloaded for an update.

Both these books are using an ‘in medias res’ style approach - they guide the reader through the essential features of Rails by building a web app from scratch. Cheap prozac, The models in the examples are creaed in SQL rather than with migrations. Cheap prozac, Let’s examine the difference on a simple example, cheap prozac, taken from AWDwR. Cheap prozac, (Further I am assuming that you have generated a rails application, cheap prozac, a development database for the application and the DB connection settings (database.yaml) are correct.)

The classic way: SQL DDL

Create the sql file, cheap prozac, create.sql:

drop table if exists products;
create table products (
id           int            not null auto_increment, cheap prozac,
title        varchar(100)   not null, cheap prozac,
description  text           not null, cheap prozac,
image_url    varchar(200)   not null, cheap prozac,
price        decimal(10, cheap prozac,2)  not null, cheap prozac,
primary key (id)
);

After this, cheap prozac, you can create the table with:

mysql name_of_your_DB < create.sql

You are now ready to generate your model.

Doing the same with migrations

In your rails app directory, cheap prozac, issue the following command:

ruby script/generate migration ProductMigration

then open the file db/migrate/001productmigration.rb and edit it. Cheap prozac, To achieve the same result as in the SQL example, cheap prozac, the file should look like this:

class ProductMigration < ActiveRecord::Migration
def self.up create_table :products do |table|
table.column :title, cheap prozac,
:string, cheap prozac,
:limit => 100, cheap prozac,
:null => false

table.column :description, cheap prozac,
:text, cheap prozac,
:null => false

table.column :image_url, cheap prozac,
:string, cheap prozac,
:limit => 200, cheap prozac,
:null => false

table.column :price, cheap prozac,
:float, cheap prozac,
:null => false
end
end

def self.down
drop_table :products
end
end

Run the migration wit the following command:

rake migrate [VERSION=version_number]

And you achieved the same result as with the first method!

That’s very nice, cheap prozac, but…

Well, cheap prozac, if the only purpose of migrations would be solely the possibility to write Ruby code instead of SQL, cheap prozac, even this would be enough for me to go for them. Cheap prozac, However, cheap prozac, i have to admit that this alone would be a rather feeble argument. Cheap prozac, The good news is that it is not! There is much more to migrations than writing Ruby code:

  • Migrations are DB agnostic - The ‘write once, cheap prozac, use everywhere’ principle really works here!
  • You don’t have to think about obscure SQL specific things anymore - let Rails handle them for you! (OK there are some really complicated things, cheap prozac, but fortunately they are adressed by some great books like Rails Recipes, cheap prozac, code snippets like Migrate Plus, cheap prozac, and I believe that by the Rails team, cheap prozac, too.)
  • You can change the database as much as you want, cheap prozac, and the data you have already there is not affected.
  • You get very effective versioning: track changes, cheap prozac, concurrent versions, cheap prozac, upgrade/downgrade your schemas easily!
  • You can generate DB schemas from migrations.
  • And possibly much much more… Cheap prozac, I am a newbie too! ;-)

In my oppinion, cheap prozac, judging based on the Rails mailing list discussions, cheap prozac, migrations are accepted more and more as the definitve way of creating, cheap prozac, maintaining, cheap prozac, versioning your DB models - so everybody considering serious Rails development should give them a look!

Similar Posts:cheap viagra,cheap prozac,ambien online stores,lasix no prescription,cheap propecia


Bad Behavior has blocked 1233 access attempts in the last 7 days.