Ruby on Rails: RESTful scaffolds, .rhtml/.rxml deprecation, and form_for( @modelname ) syntax; oh my!
I’m a newbie to Ruby on Rails. Delirious and unphased, I decided to compound this precarious position by writing my first Rails web app using Edge rails instead of the standard 1.2.x build. Three things have confused me to this point, and I’m sure more are to come. If you’re using Edge Rails, here’s hoping I can save you a few moments of frustration:
- script/generate scaffold_resource model_name (the command given in the REST Peepcode to generate a scaffold for a RESTful resource), no longer works. Instead, do this: script/generate scaffold model_name.
- When I finally did get a RESTful scaffold going, the view files for the various controller actions were given file names such as “edit.html.erb” instead of “edit.rhtml” as I was expecting. This is because .rhtml has been deprecated in Rails 2.0 (I guess because, since edit.rhtml isn’t strictly HTML, it shouldn’t have a file name that makes it look like it is; I’m not sure I buy this, but that’s the way the Rails file extensions crumble, kids). As a side-note, “.rxml” files are also deprecated in favor of “.builder” files.
- Finally, in this new “edit.html.erb” view file, I noticed that the form_for declaration looks like this: <% form_for(@modelname) do |f| %>. I had never seen this form_for syntax documented anywhere, so I proceeded to rant and rave and beat my head against the wall for awhile before I searched my own project in Textmate, and noticed that the Edge Rails CHANGELOG contained this note:
* Added record identifications to FormHelper#form_for and PrototypeHelper#remote_form_for [DHH]. Examples:
<% form_for(@post) do |f| %>
…
<% end %>This will expand to be the same as:
<% form_for :post, @post, :url => post_path(@post), :html => { :method => :put, :class => “edit_post”, :id => “edit_post_45″ } do |f| %>
…
<% end %>
Loading...
By ‘post’ do you mean the http verb or something that might go in a blog? Try to avoid accidental puns like this. It just confuses people.
JFred - December 23, 2007 at 5:09 pm
[...] good link I found on Rails 2.0 changes was by Brad Posted by arjunghosh Filed in Rails2.0, hacks, rubyonrails, upgrade Tagged: rails2.0 [...]
Some changes in Rails2.0 « The Hitchhiker’s Guide to Ruby On Rails Galaxy - January 7, 2008 at 12:28 pm
Hello there.
Just found your site. Great job!
I like it much.
look here http://live.com
occalmamouG - March 3, 2008 at 2:23 pm
Cialis
There are some people who say that top branded drugs are way more effective than the generic ones. However, this does not hold much truth when it comes to the generic medicines which are sold here. An online pharmacy which offers generic medicines at affordable prices. If you have been diagnosed with a sickness and your medication requires you to spend a lot for your medicines, you don’t have to worry about this anymore. You can buy cialis and get a discount when you keep on buying the same drug. When you cannot tolerate the high price of branded medicines, your only option is an online pharmacy, since it is compassionate with your need for reasonably priced drugs.
If your medication calls for high-priced branded medicines, why not generic cialis? This is an alternative which is provided at your affordable online drug store. One of the advantages that you can get from this store is the fact that its medicines can be bought for very low prices. You can order generic drugs at the website. These medicines are formulated with ingredients which are equal to the ones which make up branded drugs. However, the prices of the two are entirely different. Even though the prices of generic drugs and branded drugs vary widely, the effects are still the same. This is due to the fact that the medicines which are sold at this online pharmacy have been approved by worldwide organizations. The effectiveness and the quality of the generic drugs are regarded as excellent. The legality of these drugs has been supported by international regulatory boards. Some of these authorities are South Africa MCC, USA FDA, and WHO.
When you buy cialis, the shipping service is offered for free. If you are residing within the European continent or at the other pole of the globe, the medicines that you have ordered will still be delivered to you. If you are a resident from the USA or from Europe, the duration of the shipping service can take fourteen days. One of the services that this online drug store provides its customers with is the chance to get a discount. Each time you order the same drug, you will be offered with a five-percent discount. Since the online pharmacy is compassionate with the plight of its sick patients, it does not charge you with hidden fees. Nor does it charge you when you consult with its physicians.
You can buy cialis when you are diagnosed with a sickness. Serious ailments such as cancer or manic depression can be treated with some of the medicines sold at this online pharmacy.
Author: Mark Garet
markgaret - November 10, 2008 at 3:20 pm