Quite a lot has changed since Rails 1, and I was really impressed by the people who are willing to spend time to sit down with Rails 3 and learn the differences (1). The community should welcome them and RTFM's are not helping. Here I think I can help.
I would write this in Rails 3:
<%= form_for(@album) do |f| %>
<p>
<%= f.label :title %>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :artist %>
<%= f.text_field :artist %>
</p>
<p>
<%= f.label :genre %>
<%= f.text_field :genre %>
</p>
<p>
<%= f.label :release_date %>
<%= f.datetime_select :release_date %>
</p>
<%= f.submit %>
<% end %>
Woah, so many changes! Where to begin? Top line, of course!
form_for - , Rails . @album, , , : 1) 2) .
, , app/views/albums/new.html.erb :
<h2>New Album</h2>
<%= render "form" %>
OMG, ! : render "form" /views/albums/ _form.html.erb. , form_for . ? .
AlbumsController new - :
def new
@album = Album.new
end
form_for , : ", Album, , , create , Rails", , .
:
, albums_path. ?
Ruby on Rails 2 RESTful . , , , . : RESTful - URL- , , , POST ( , ?) /, create.
Rails ?
config/routes.rb :
resources :albums
"" (, , , , ). , , .
, form_for. , /albums , . , f? , Album new ( , edit). :
<%= f.text_field :title %>
Rails 1:
<%= text_field :album, :title %>
, Rails , .
, , . , :title, Title. :release_date " ". .
f.submit. , " ", @album - , " ", . ?
edit!
def edit
@album = Album.find(params[:id]
end
app/views/albums/edit.html.erb , new.html.erb sibling:
<h2>Editing Album</h2>
<%= render "form" %>
, -, ( ).
edit, , /albums/1 Rails-speciality PUT . , , .
, , , , , .
3 .
(1) , , .