HeLp oN my database

Using my application i can able to save a new record into my db
but i cannot update a existing record into my db.
using update query i can able to update my records.
but using update_attributes it doesnot update my records.
even i cant find any errors in logs or something.
throughout my application i can able to save a new record but unable to
update my existing records.
actually i have changed my application to new db.since then i face these
issues.
before changing the db the application was working fine..
so wat would be problem in my database or something...where i have to
lookup
Kindly Provide Me Your Views for my issue..

Thanks a bunch
Have a Nice daY

Please post the code which attempts to update the record.
If you are using update_attributes what return value is it giving.
Is it possible that you have validations that are failing?

Colin

Colin Law wrote:

before changing the db the application was working fine..
so wat would be problem in my database or something...where i have to
lookup
Kindly Provide Me Your Views for my issue..

Please post the code which attempts to update the record.
If you are using update_attributes what return value is it giving.
Is it possible that you have validations that are failing?

Colin

Thank You for the Reply.

Kindly find my code below

if request.post? and params[ :id ] and params[ :newsinfo ]

  @newsinfo = News.find(params[:id])

  sql = "UPDATE news SET newstext = 'today' "

  @check = ActiveRecord::Base.connection.execute(sql)

  if @newsinfo.update_attributes(params[:newsinfo])

    flash[:notice] = "news has been successfully modified, click 'edit'
to modify and 'remove' to delete flash news"

    redirect_to :controller => 'news', :action => 'list'

   else

       puts @newsinfo.errors.inspect

   end

end

sql = "UPDATE news SET newstext = 'today' "

@check = ActiveRecord::Base.connection.execute(sql)

this code updates the db

but the below code not works still no errors

if @newsinfo.update_attributes(params[:newsinfo])

    flash[:notice] = "news has been successfully modified, click 'edit'
to modify and 'remove' to delete flash news"

    redirect_to :controller => 'news', :action => 'list'

   else

       puts @newsinfo.errors.inspect

   end

the control goes to if condition only.no validation errors

Any suggestion on this.

Thanks for information

Have a Pleasent daY

....
but the below code not works still no errors

if @newsinfo.update_attributes(params[:newsinfo])

flash[:notice] = "news has been successfully modified, click 'edit'
to modify and 'remove' to delete flash news"

redirect_to :controller => 'news', :action => 'list'

else

  puts @newsinfo\.errors\.inspect

end

the control goes to if condition only.no validation errors

Do you mean it goes to to the else condition but shows no errors? Or
do you mean it passes the if test but the data is not updated in the
db?

Colin

Colin Law wrote:

else

  puts @newsinfo\.errors\.inspect

end

the control goes to if condition only.no validation errors

Do you mean it goes to to the else condition but shows no errors? Or
do you mean it passes the if test but the data is not updated in the
db?

Colin

Thanks for the reply...
it goes to the if statement only but not updating the records...

Processing NewsController#modify (for 192.168.0.82 at 2009-11-12
14:25:40) [POST]
Parameters: {"commit"=>"Edit", "id"=>"1",
"newsinfo"=>{"newstext"=>"revafgtfggfffrtyhrthfgjh"}}
  e[4;36;1mSQL (0.0ms)e[0m e[0;1mSET SQL_AUTO_IS_NULL=0e[0m
::: Checking session expiry
::: Session has not expired. Reinitialising.
::: Initializing session expiry. Expires at Thu Nov 12 16:05:40 +0530
2009
  e[4;35;1mUserInfo Columns (15.0ms)e[0m e[0mSHOW FIELDS FROM
`userinfo`e[0m
  e[4;36;1mUserInfo Load (0.0ms)e[0m e[0;1mSELECT * FROM `userinfo`
WHERE (`userinfo`.`id` IS NULL) LIMIT 1e[0m
  e[4;35;1mNews Columns (16.0ms)e[0m e[0mSHOW FIELDS FROM `news`e[0m
  e[4;36;1mNews Load (0.0ms)e[0m e[0;1mSELECT * FROM `news` WHERE
(`news`.`id` = 1) e[0m
  e[4;35;1mSQL (0.0ms)e[0m e[0mBEGINe[0m
  e[4;36;1mSQL (0.0ms)e[0m e[0;1mCOMMITe[0m
Redirected to actionlistcontrollernews
Completed in 63ms (DB: 31) | 302 Found
[http://192.168.0.82/news/modify/1]

this is the log when i modify my news.

it has only one field .the field is newstext.

still its not getting updated.

Any Ideas

Colin Law wrote:

else

  puts @newsinfo\.errors\.inspect

end

the control goes to if condition only.no validation errors

Do you mean it goes to to the else condition but shows no errors? Or
do you mean it passes the if test but the data is not updated in the
db?

Colin

Thanks for the reply...
it goes to the if statement only but not updating the records...

Processing NewsController#modify (for 192.168.0.82 at 2009-11-12
14:25:40) [POST]
Parameters: {"commit"=>"Edit", "id"=>"1",
"newsinfo"=>{"newstext"=>"revafgtfggfffrtyhrthfgjh"}}
[4;36;1mSQL (0.0ms) [0m [0;1mSET SQL_AUTO_IS_NULL=0 [0m
::: Checking session expiry
::: Session has not expired. Reinitialising.
::: Initializing session expiry. Expires at Thu Nov 12 16:05:40 +0530
2009
[4;35;1mUserInfo Columns (15.0ms) [0m [0mSHOW FIELDS FROM
`userinfo` [0m
[4;36;1mUserInfo Load (0.0ms) [0m [0;1mSELECT * FROM `userinfo`
WHERE (`userinfo`.`id` IS NULL) LIMIT 1 [0m
[4;35;1mNews Columns (16.0ms) [0m [0mSHOW FIELDS FROM `news` [0m
[4;36;1mNews Load (0.0ms) [0m [0;1mSELECT * FROM `news` WHERE
(`news`.`id` = 1) [0m
[4;35;1mSQL (0.0ms) [0m [0mBEGIN [0m
[4;36;1mSQL (0.0ms) [0m [0;1mCOMMIT [0m

There should be an UPDATE here, so for some reason rails is not
changing the record. Are you absolutely sure that the field newstext
has not already got the value revafgtfggfffrtyhrthfgjh? Have a look
in phpmyadmin or whatever tool you use to look at the db and check.

Otherwise please post the complete code for NewsController#modify.

Colin