Problem editing a page with 0.6.2 (gem)

Hello,

I just updated my installation to 0.6.2 with gem update and followed
the instructions, did rake db:migrate and all that. Now, when I want
to save a page, I get this:

Any idea why?

Processing PageController#edit (for 192.93.23.254 at 2007-06-26
10:49:34) [POST]
Session ID: 42454526596a79897360bb3e7633a97d
Parameters: {“commit”=>“Save Changes”, “part”=>{“0”=>{“name”=>“body”,
“filter_
id”=>“Textile”, “content”=>"<div class=“left”>\r\n
!/images/leviathan.png(Eye
with Pyramid)!\r\n\r\n\r\n<div class=“main”>\r\n\r\nCalife is
small pro
gram that enable a system administrator to become root (or another user)
on his/
her machines without giving the root password but his/her
own.\r\n\r\nThe most i
[…]
ry famous french comic taking place in an turkish/mideast country
whereas the pr
incipal character - the Grand Vizir named “Iznogoud” - is always
making plans
to become “Calife” in place of the “Calife”.\r\n"}},
“action”=>“edit”, “id”=

“8”, “controller”=>“admin/page”, “page”=>{“slug”=>“calife”, “class_name”=>“Page
“, “title”=>“Calife: how to become root (or another user) with one’s own
passwor
d”, “breadcrumb”=>“Calife: how to become root (or another user) with
one’s own p
assword”, “lock_version”=>””, “status_id”=>“100”, “layout_id”=>""}}

NoMethodError (undefined method +' for nil:NilClass): /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li b/active_record/locking/optimistic.rb:64:inupdate_without_callbacks’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li
b/active_record/callbacks.rb:267:in update_without_timestamps' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li b/active_record/timestamp.rb:48:inupdate’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li
b/active_record/base.rb:1789:in create_or_update_without_callbacks' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li b/active_record/callbacks.rb:242:increate_or_update’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li
b/active_record/base.rb:1545:in save_without_validation' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li b/active_record/validations.rb:752:insave_without_transactions’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li
b/active_record/transactions.rb:129:in save' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li b/active_record/connection_adapters/abstract/database_statements.rb:59:intrans
action’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li
b/active_record/transactions.rb:95:in transaction' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li b/active_record/transactions.rb:121:intransaction’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/li
b/active_record/transactions.rb:129:in save' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/app/controllers/admin/page_c ontroller.rb:110:insave’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/app/controllers/admin/abstra
ct_model_controller.rb:116:in handle_new_or_edit_post' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/app/controllers/admin/page_c ontroller.rb:25:inedit’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/base.rb:1095:in send' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/base.rb:1095:inperform_action_without_filters’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/filters.rb:632:in call_filter' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/filters.rb:638:incall_filter’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/filters.rb:438:in call' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/filters.rb:637:incall_filter’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/filters.rb:638:in call_filter' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/filters.rb:438:incall’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/filters.rb:637:in call_filter' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/filters.rb:638:incall_filter’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/filters.rb:438:in call' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/filters.rb:637:incall_filter’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/filters.rb:619:in perform_action_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/benchmarking.rb:66:inperform_action_without_rescue’
/usr/local/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/benchmarking.rb:66:inperform_action_without_rescue’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/rescue.rb:83:in perform_action' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/base.rb:430:insend’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/base.rb:430:in process_without_filters' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/filters.rb:624:inprocess_without_session_management_support’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/session_management.rb:114:in process_without_test' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/ action_controller/test_process.rb:15:inprocess’
/usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/actionpack/lib/
action_controller/base.rb:330:in process' /usr/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/railties/lib/di spatcher.rb:41:indispatch’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in
process' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in
synchronize’

Line 64 in optimistic.rb is

  def update_with_lock #:nodoc:
    return update_without_lock unless locking_enabled?

    lock_col = self.class.locking_column
    previous_value = send(lock_col)
    send(lock_col + '=', previous_value + 1)      <<<<<<< line 64

    affected_rows = connection.update(<<-end_sql, 

“#{self.class.name} Update
with optimistic locking”)
UPDATE #{self.class.table_name}
SET #{quoted_comma_pair_list(connection,
attributes_with_quotes(false)
)}
WHERE #{self.class.primary_key} = #{quote_value(id)}
AND #{self.class.quoted_locking_column} =
#{quote_value(previous_value
)}
end_sql

    unless affected_rows == 1
      raise ActiveRecord::StaleObjectError, "Attempted to update a 

stale obj
ect"
end

    return true
  end

From your trace, I’m guessing that the lock column isn’t being initialized to a default value of zero, and null values are screwing
it up.

What db are you using?

On 6/27/07, Daniel S. [email protected] wrote:

From your trace, I’m guessing that the lock column isn’t being initialized to a default value of zero, and null values are screwing
it up.

What db are you using?

In that case, postgresql 8.2.3 running on FreeBSD 6.1.

Thanks for your answer, I was becoming quite depressed…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs