If an active record is returned as a result of a find_by_sql() query, what must be true in order for it to be save-able? Here's an example of it not working: ===== require 'rubygems' require 'active_record' ActiveRecord::Schema.define do create_table(:blurgs, :force => true) {|t| t.string :name } end class Blurg < ActiveRecord::Base end
a = Blurg.create(:name => "tic") p "a.name = #{a.name}" p "Blurg.count => #{Blurg.count}" b = Blurg.find_by_sql('SELECT \'tac\' as name') p "b = #{b}" p "b.first.name = #{b.first.name}" p "b.first.save! => #{b.first.save!}" p "Blurg.count => #{Blurg.count}" ===== which produces ===== "a.name = tic" "Blurg.count => 1" "b = [#<Blurg name: \"tac\">]" "b.first.name = tac" "b.first.save! => true" "Blurg.count => 1" ===== So even though b.first has a .name value, calling b.first.save! silently fails to store it in the database. Is there a way to detect whether a record can be saved or not? Or at least give an error when you try to save it? - ff -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.