[前][次][番号順一覧][スレッド一覧]

rails:1836

From: Kyoko Sato <k.sato@a...>
Date: Wed, 15 Nov 2006 19:39:26 +0900
Subject: [rails:1836] Re: 既存のデータベースとscaffold

お世話になっております。佐藤です。
三浦さんのやり方で、listの表示は出来ていたのですが、Edit, Show を表示す
ると、下記のようなエラーが発生してしまいました。
他のプロジェクトのファイルを見ても、うまくいっているファイルと同じように
見えているので、何か別の設定が必要なのかなと思っているのですが、どうなの
でしょうか?
よろしくお願い致します。

--------account_controller.rb-------------------------------------------

class AccountController < ApplicationController
  def index
    list
    render :action => 'list'
  end

  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

  def list
    @account_pages, @account = paginate :account, :per_page => 10
  end

  def show
    @account = Account.find(params[:id])
  end

  def new
    @account = Account.new
  end

  def create
    @account = Account.new(params[:account])
    if @account.save
      flash[:notice] = 'Account was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end

  def edit
    @account = Account.find(params[:id])
  end

  def update
    @account = Account.find(params[:id])
    if @account.update_attributes(params[:account])
      flash[:notice] = 'Account was successfully updated.'
      redirect_to :action => 'show', :id => @account
    else
      render :action => 'edit'
    end
  end

  def destroy
    Account.find(params[:id]).destroy
    redirect_to :action => 'list'
  end
end


--------------------edit.rhtml-------------------------------------------
<h1>Editing account</h1>

<%= start_form_tag :action => 'update', :id => @account %>
  <%= render :partial => 'form' %>
  <%= submit_tag 'Edit' %>
<%= end_form_tag %>

<%= link_to 'Show', :action => 'show', :id => @account %> |
<%= link_to 'Back', :action => 'list' %>

--------------------show.rhtml-------------------------------------------
<% for column in Account.content_columns %>
<p>
  <b><%= column.human_name %>:</b> <%=h @account.send(column.name) %>
</p>
<% end %>

<%= link_to 'Edit', :action => 'edit', :id => @account %> |
<%= link_to 'Back', :action => 'list' %>

--------------------show error-------------------------------------------
Couldn't find Account without an ID

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:939:in
`find_from_ids'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:382:in `find'
app/controllers/account_controller.rb:16:in `show'

--------------------edit error-------------------------------------------
Couldn't find Account without an ID

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:939:in
`find_from_ids'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:382:in `find'
app/controllers/account_controller.rb:34:in `edit'



--
ML: rails@r...
使い方: http://QuickML.com/

[前][次][番号順一覧][スレッド一覧]

      1799 2006-11-06 12:15 [katayama@l...       ] Railsサイトを開設しました               
      1800 2006-11-06 12:58 ┗[tf@s...             ]                                       
      1801 2006-11-06 13:09  ┗[katayama@l...       ]                                     
      1802 2006-11-06 13:27   ┗[tf@s...             ]                                   
      1803 2006-11-06 13:39    ┗[katayama@l...       ]                                 
      1804 2006-11-06 13:54     ┗[tf@s...             ]                               
      1805 2006-11-06 14:08      ┣[tf@s...             ]                             
      1812 2006-11-09 08:38      ┗[katayama@l...       ]                             
      1813 2006-11-09 09:51       ┗[k.sato@a...         ] 既存のデータベースとscaffold
      1814 2006-11-09 09:59        ┣[kazuhiko@f...       ]                         
      1815 2006-11-09 10:34        ┃┗[k.sato@a...         ]                       
      1816 2006-11-09 10:43        ┃ ┗[k.sato@a...         ]                     
      1817 2006-11-09 10:52        ┃  ┗[sakuro@e...         ]                   
      1818 2006-11-09 11:01        ┃   ┗[k.sato@a...         ]                 
      1819 2006-11-09 11:37        ┃    ┣[sakuro@e...         ]               
      1820 2006-11-09 11:51        ┃    ┃┗[k.sato@a...         ]             
      1821 2006-11-09 12:00        ┃    ┃ ┣[daisaito@l...       ]           
      1822 2006-11-09 12:35        ┃    ┃ ┗[naoji@t...          ]           
      1859 2006-11-30 06:42        ┃    ┗[k.sato@a...         ]               
      1823 2006-11-09 15:18        ┗[issei.m@g...        ]                         
      1835 2006-11-15 09:31         ┣[k.sato@a...         ]                       
->    1836 2006-11-15 11:39         ┃┗[k.sato@a...         ]                     
      1837 2006-11-15 12:09         ┃ ┗[issei.m@g...        ]                   
      1838 2006-11-15 13:01         ┃  ┗[andyjpn@g...        ]                 
      1878 2006-12-07 07:19         ┗[k.sato@a...         ] WEBrickが起動してくれません
      1879 2006-12-07 07:35          ┗[sakuro@e...         ]                     
      1880 2006-12-07 09:25           ┗[k.sato@a...         ]