Nov 4, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / POST falling back to GET method

Kero!

You wrote “the GET method URL”, but GET and POST (and PUT) methods may (in general) be applied to the same URL… Do you find out from the log file that “all requests to add_to_cart are using a GET method instead of POST”?

 
Oct 14, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / jquery

jQuery is not a mainstream in the Rails world, but it’s certainly worth to be mentioned as a fine alternative.

 
Sep 29, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Change Scaffolded String to Decimal

To change ‘rating’ from string to decimal you should
(1) script/generate migration ChangePosts

(2) describe the changing of the column in the generated migration file:
class ChangePosts < ActiveRecord::Migration; def self.up; change_column :posts, :rating, :decimal; end; def self.down; change_column :posts, :rating, :string; end;
end;

(3) run the migration by ’ rake db:migrate ‘

 
Sep 21, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / question about single table inheritance

(As my son Lev said: “every class hierarchy should be disigned according to the certain situation”.) The example of the class tree in chapter 18 (Employee < Person, Customer < Person) expresses the idea of INHERITANCE: “ALL employess and ALL customers are people”.

In this hierarchy the notion of an “employee also being a customer” can’t be expressed only by inheritance: it’s not quite natural for an Employee to be a subcluss of a Customer or vice versa. And introducing a special attribute or method to distinguish an employee form customer is certainly an ugly decision.

In many situations the realization of inheritance in Rails (STI) helps us to elegantly represent a group of closely related classes with common attributes in the parent class and specific attributes in child classes. (And this kind of inheritance is NOT MULTIPLE: the parent class is always ONE.)

But there are many situations where inter-relationships between the classes express the idea of ASSOCIATION, for example: SOME persons may study as students and SOME (or none) of them may work as teachers. (Persons that can work as employees and those of them that may have contracts as customers are 2 subsets of People that can overlap just partially.) Such relationships should be better expressed as polymorphic associations or, maybe, has_many :through relationship.

 
Sep 21, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / AWS/SOAP suggestion

The AWDwR book has from the 1st edition been the best and most profound tutorial and reference about Rails. And the 25th chapter about AWS & SOAP could greatly help the developers who write applications interacting with non-REST web-services.

 
Sep 18, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Primary Keys

Martin!
1. If you decide which primary key to use, then do chhose a surrogate integer PK: it’ll save you much time in future.
2. Before appointing another column as the primary key, you needed to populate it by unique integer values (e.g. renumber the records).
3. If you work with a legacy DB, in which you can’t switch to another PK, it’s possible to use a non-numeric PK. But you’ll have to write a method for generating the keys to new records (def before_create; self.id = generate_next_id; end).

 
Aug 23, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Views without actions?

But, Wayde, if you (1) put in your routes.db file the route to the default controller:

map.connect ’:action’, :controller => ‘pages’
map.root :controller => ‘pages’

(2) delete the public/index.html
(3) create the app/controllers/pages_controller.rb WITHOUT actions
(3) create the app/views/pages/about.html.erb and app/views/pages/contact.html.erb templates

you’ll get the needed dynamic “Views without actions”!

 
Aug 23, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Rails 2.0.2 with this AWDWR Book

One of the most attracting features in the coming 2.2 version is the standardized internationalization support, which ia VERY imporant in our multi-nations wortld. Hope, it’ll be described in Chapter 15.

 
Aug 19, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Views without actions?

Wayde, “the best way to handle such static resources” is to make ‘em static: you may simply create the file public/about/index.html and access it by pointing the browser to http://localhost:3000/about – it works fine (at least in Firefox and Opera). But this will be a STATIC file, not a view…

 
Aug 11, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Pag. 79 - Culture

Sam, will the questions of i18n be covered in the 3rd edition?

 
Aug 7, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / So what's new?

Alan,
IMHO this book is for people who have a certain level of experience in programming, but are new to the “Rails Way”. If you have some difficulties, you probably need to read a more introductory book in parallel?
There are some pretty ones, e.g. “Simply Rails 2.0” by Patrick Lenz. – Collingwood: SitePoint, 2008.
I’m a programmer for more than 25 years and I’m still learning… :-)

 
Aug 7, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Digital Products

What do you mean by “digital product support”? Please give a bit more detailed info about waht you want…

 
Aug 7, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / page 73 db:migrate

Ciaran, when you tried to run “rake db:migrate” you got the “unknown database” error because the DB, described in config/database.yml, didn’t exist. And the “db:create” task created the needed database. Before “db:create” was added to the Rails tasks, you had to create the databases manually by the DB-specific tools.

 
Aug 7, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Text Editors for Rails (p38)

I came across a newer review, in which 9 IDEs for RoR are compared: http://www.infoworld.com/article/08/07/07/28TC-ruby-ides_1.html
BTW, the only “Excellent”/9.0 mark was given to my favourite NetBeans IDE. :-)

 
Jul 31, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Text Editors for Rails (p38)

There’s a good review of the Ruby/Rails IDE/editors at: http://www.tbray.org/ongoing/When/200x/2007/11/26/Ruby-Tool-Survey
I personally prefer NetBeans-6 for my Rails projects (for I love its good SVN support and fine code completeion). But to make small changes in 1 or 2 source files, I use Kate editor under Linux. Or sometimes, gedit…

 
Jul 19, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Pagination

The extension of RoR with plugins may be shown by the ‘will_paginate’ as an example, because pagination is a VERY common task…

 
Jul 19, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Help with XML

Stephen, can you give an example of the XML document to be generated and sent?

 
Jun 22, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / NetBeans?

I love NetBeans 6 as a fine cross-platform IDE and I often use it. All the samples from this book can certainly be easily viewed and run under NetBeans.

 
Jun 18, 2008
M_v_shokhirev_small Mikhail V. S... 19 posts

Topic: Agile Web Development with Rails, 3rd Edition / Chapter 3: Installing Rails - Keep it!

I suggest a small but useful addition to the Chapter 3 “Installing Rails”: consider mentioning the Bitnami.org’s RubyStack installer. The reasons are:
(1) its graphical install wizard is very simple for the beginners and convenient for advanced developers;
(2) it is multi-platform (Linux, Mac x86, Mac PPC, Solaris x86, Solaris SPARC, Windows);
(3) the developer installation includes almost all the necessary tools (Apache, ImageMagick, Mongrel, MySQL, Ruby, Rails, Rmagick, RubyGems, OpenSSL, phpMyAdmin (for MySQL), SQLite3, Subversion, zlib, ...);
(4) the production variant of the installation is optimized for speed & productivity;
(5) it’s installed in one directory and doesn’t modify anything else in the system.
I use it under Linux, Mac and Windows and I’m quite satisfied with it, indeed. To my opinion, it’s quite pragmatic and especially useful for developing and testing cross-platform applications as well as for unified training samples.

19 posts