【Ruby】Ruby on Rails Part7
■ このスレッドは過去ログ倉庫に格納されています
0403nobodyさん
2009/06/23(火) 16:58:51ID:???Four Days on Rails 2.0(日本語)を公開します
http://rails.to/articles/2008/05/05/4-days-on-rails-2-0-released
http://localhost:3000/items/ から 一覧の編集アイコンより
http://localhost:3000/items/14/edit に飛んでちゃんとItemが編集できます。
Railsは通常、/Controller/Action/id のようになっていると思っていたのですが、
上記の例だとURLが/Controller/id/Action/ になっているようです。
これってどういうことなんでしょうか?
該当リンク元は以下のようになっていて、( app/views/items/_index_stripes.html.erb )
<td><%= link_to show_image('edit'), {:controller => 'items', :action => 'edit', :id => index_stripes.id} %></td>
コンロトーラーは以下のようになってます。 app/controllers/items_controller.rb
# GET /items/1/edit
def edit
@item = Item.find(params[:id])
end
config/routes.rb は、以下のような感じ。(必要なところのみ記述)
ActionController::Routing::Routes.draw do |map|
map.resources :notes
map.resources :items
map.resources :categories
map.root :controller => "items"
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
というか、ほとんど、今見たら、scaffoldしたままですね…。
環境: Rails 2.3.2, Ruby 1.8.7, Windows XP SP3
■ このスレッドは過去ログ倉庫に格納されています