Weird issue with editing data

Hi all.

Ive got a small CRUD app that is giving me some weird isuses.

If I add/create an entry that works fine, the data goes into the db. I
can later show the data, but when I edit it, no data is displayed in the
form for me to edit.

Here is the bits from the controller.

def new
@kb=Knowledgebase.new
end

def create
@kb= Knowledgebase.new(params[:kb])
if @kb.save
flash[:notice] = ‘New knowledge base article created.’
redirect_to :action => ‘index’
else
render :action =>‘new’
end
end

def list
@kb_pages, @kb = paginate :knowledgebase, :per_page => 10, :order =>
“created_on DESC”
end

def show
@kb = Knowledgebase.find(params[:id])
end
def edit
@kb = Knowledgebase.find(params[:id])
end

def update
@kb = Knowledgebase.find(params[:id])
if @kb.update_attributes(params[:kb])
flash[:notice] = ‘Knowledge Base article was successfully
updated.’
redirect_to :action => ‘show’, :id => @kb
else
render :action => ‘edit’
end
end

Here is the edit.rhtml and partial

<%= start_form_tag :action => ‘update’, :id => @kb %>
<%= render :partial => ‘form’ %>
<%= submit_tag ‘Edit’ %>
<%= end_form_tag %>

<%= error_messages_for ‘knowledgebase’ %>

Title
<%= text_field 'kb', 'title'%>

Short Description
<%= text_field 'kb', 'short_description', :size => "90" %>

<%=text_area 'kb', 'details', :cols=>"90" %>

and from the development.log file when I request to edit the entry

Processing KnowledgebaseController#edit (for 192.168.0.134 at 2006-07-27
13:06:05) [GET]
Session ID: ec4872507e0920d37da1153822c0cd4d
Parameters: {“action”=>“edit”, “id”=>“1”,
“controller”=>“knowledgebase”}
User Columns (0.053923) SHOW FIELDS FROM users
Rendering within layouts/knowledgebase
Rendering knowledgebase/edit
Rendered knowledgebase/_form (0.00072)
Rendered home/_navigation (0.00013)
Completed in 0.06913 (14 reqs/sec) | Rendering: 0.00429 (6%) | DB:
0.05392 (78%) | 200 OK [http://192.168.0.117/knowledgebase/edit/1]

Any insights as to why the data is never grabbed from the db? Ive
confirmed its there, and it does show with a show request.

Many thanks

Jonathan

Hi Jonathan,

I don know what thing brought u this kind of error but one thing I’ve
been
able to see is in the edit.rhtml view (or maybe u hadn’t copy well from
your
code ).

def edit
@kb = Knowledgebase.find(params[:id])
end

@kb = one line from your knowledgebase table…so in edit.rhtml u should
do
:id => @kb.id

*Here is the edit.rhtml and partial

<%= start_form_tag :action => ‘update’, :id => @kb %>
<%= render :partial => ‘form’ %>
<%= submit_tag ‘Edit’ %>
<%= end_form_tag %>


*Hope this works…