routing error の件

とりあえず最初の状態に戻して正常動作を確認。がしかしこのままでは使いものにならないので、scaffold で作成したソレについては、以下の機能を削除の方向。

  • 新規作成
  • 更新
  • 削除 (はあっても良いのかどうか)

別な controller からこれらの機能を云々する方が良さげ。別な controller を作った上で index, new, create, update, destroy な action を作り routing は resource でヤッツケれば form_for が使えるのかどうか。

ヤッてみます

とりあえず routes.rb なソレは以下な方向。閲覧のみ。

  resources :resavations, only: [:index, :show]

で、以下なのか。って controller の名前どうするか。面倒なので適当に付けることに。

$ rails g controller Vmresavations index new create edit update destroy
      create  app/controllers/vmresavation_controller.rb
       route  get "vmresavation/destroy"
       route  get "vmresavation/update"
       route  get "vmresavation/edit"
       route  get "vmresavation/create"
       route  get "vmresavation/new"
       route  get "vmresavation/index"
      invoke  erb
      create    app/views/vmresavation
      create    app/views/vmresavation/index.html.erb
      create    app/views/vmresavation/new.html.erb
      create    app/views/vmresavation/create.html.erb
      create    app/views/vmresavation/edit.html.erb
      create    app/views/vmresavation/update.html.erb
      create    app/views/vmresavation/destroy.html.erb
      invoke  rspec
      create    spec/controllers/vmresavation_controller_spec.rb
      create    spec/views/vmresavation
      create    spec/views/vmresavation/index.html.erb_spec.rb
      create    spec/views/vmresavation/new.html.erb_spec.rb
      create    spec/views/vmresavation/create.html.erb_spec.rb
      create    spec/views/vmresavation/edit.html.erb_spec.rb
      create    spec/views/vmresavation/update.html.erb_spec.rb
      create    spec/views/vmresavation/destroy.html.erb_spec.rb
      invoke  helper
      create    app/helpers/vmresavation_helper.rb
      invoke    rspec
      create      spec/helpers/vmresavation_helper_spec.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/vmresavation.js.coffee
      invoke    scss
      create      app/assets/stylesheets/vmresavation.css.scss

これ、show が無いからバッティング無いよね、ってアレなのかな。API ベースで考えると無問題なはず。Web でどうするかは別途考えよ。ちなみに作った時点で試験ってパスするんかな。って実行してみるとがっつり失敗。むむむ。
と思ったら controller なクラスとか空っぽだww 書くか。てその前に routing なソレが以下になってますね。

          vmresavation_index GET    /vmresavation/index(.:format)         vmresavation#index
            vmresavation_new GET    /vmresavation/new(.:format)           vmresavation#new
         vmresavation_create GET    /vmresavation/create(.:format)        vmresavation#create
           vmresavation_edit GET    /vmresavation/edit(.:format)          vmresavation#edit
         vmresavation_update GET    /vmresavation/update(.:format)        vmresavation#update
        vmresavation_destroy GET    /vmresavation/destroy(.:format)       vmresavation#destroy

config/routes.rb な記述は以下。これは微妙。

  get "vmresavation/index"
  get "vmresavation/new"
  get "vmresavation/create"
  get "vmresavation/edit"
  get "vmresavation/update"
  get "vmresavation/destroy"

index なソレは以下にするべきなのか。あとそれ以外も resource 使わないと、って事で。

  resources :vmresavation, only: [:new, :create, :edit, :update, :destroy]
  match 'vmresavation/:id', :to => 'vmresavation#index', :as => 'vmresavations', :via => :get

rake routes の出力の一部が以下。

          vmresavation_index POST   /vmresavation(.:format)               vmresavation#create
            new_vmresavation GET    /vmresavation/new(.:format)           vmresavation#new
           edit_vmresavation GET    /vmresavation/:id/edit(.:format)      vmresavation#edit
                vmresavation PUT    /vmresavation/:id(.:format)           vmresavation#update
                             DELETE /vmresavation/:id(.:format)           vmresavation#destroy
              vm_resavations GET    /vmresavation/:idx(.:format)          vm_resavation#index

controller 方面は先に scaffold で作ってたソレをパクりました。view も空ですね。なのでこちらも先に scaffold で作成したナニを (ry

動作確認してみた

色々微妙。新規作成にあたっては選択してはいけない項目がありますね。とりあえず続きは明日ってことでorz