Topic: Clicking on Edit not going anywhere

HI,

I recently upgraded to Instant Rails 1.4. Earlier my code was running on webrick and now it is running on Mongrel 0.3.13.3.

I copied my applicaion from my old rails_apps directory to the new rails_apps directory.

This is my problem.

I have a model class named AmBa and  the contents of that are below

class AmBa < ActiveRecord::Base
has_and_belongs_to_many :am_applications
end

My controller is as follows
class AmBasController < ApplicationController
  def index
    list
    render :action => 'list'
  end



  def list
    @am_ba_pages, @am_bas = paginate :am_bas, :per_page => 10
  end

  def show
    @am_ba = AmBa.find(params[:id])
  end

  def new
    @am_ba = AmBa.new
  end

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

  def edit
    @am_ba = AmBa.find(params[:id])
  end

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

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


and finally my view for Edit is as follows

<h1>Editing am_ba</h1>

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

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


When I click on Edit on my web browser it shows me the record to edit but when I change something and press Edit to save my chagnes nothing happens.

Here is the relevant log output.

Processing AmBasController#edit (for 127.0.0.1 at 2006-11-14 14:09:17) [GET]
  Session ID: ba00613006f1059e97a2d56f0abb89ef
  Parameters: {"action"=>"edit", "id"=>"10001", "controller"=>"am_bas"}
  AmBa Load (0.000000)   select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM am_bas WHERE (am_bas.id = '10001') ) raw_sql_ where rownum <= 1) where raw_rnum_ > 0
Rendering  within layouts/application
Rendering am_bas/edit
  AmBa Columns (0.000000)   
select column_name, data_type, data_default, nullable,
decode(data_type, 'NUMBER', data_precision,
'VARCHAR2', data_length,
null) as length,
decode(data_type, 'NUMBER', data_scale, null) as scale
from all_tab_columns
where owner = 'RAKESH'
and table_name = 'AM_BAS'
order by column_id

Rendered am_bas/_form (0.00000)
Completed in 0.03000 (33 reqs/sec) | Rendering: 0.02000 (66%) | DB: 0.00000 (0%) | 200 OK [http://localhost/am_bas/edit/10001]

Re: Clicking on Edit not going anywhere

Is the record you're trying to Edit being saved?

Add:

<%= error_messages_for('am_ba') %>

As part of your edit.rhtml, or preferably inside of the _form partial for the AmBa objects.

This will tell Rails to output the error messages and reasons why AmBa couldn't be saved.

Ruby Rockstars - Ruby Jobs for all!