slim_scrooge icon indicating copy to clipboard operation
slim_scrooge copied to clipboard

read_attribute doesnt work with Rails 3.2.15

Open bhushangahire opened this issue 9 years ago • 2 comments

I have a code in model to update column to have custom text appended.

def name read_attribute(:name) + " (N)" if read_attribute(:name).present? end

Its not working with this plugin. Is it bcas its not compatible with rails 3.2 or I can fix it with minor code change?

ActiveRecord::StatementInvalid - Mysql2::Error: Unknown column '174' in 'where clause': SELECT markets.name,markets.division_id,markets.active,markets.creator_id,markets.updater_id,markets.created_at,markets.updated_at,markets.market_type,markets.short_name,markets.time_zone_id,markets.region_id,markets.country_id,markets.state_id,markets.id FROM markets WHERE id IN (174,197): activerecord (3.2.15) lib/active_record/connection_adapters/abstract_adapter.rb:285:in rescue in log' activerecord (3.2.15) lib/active_record/connection_adapters/abstract_adapter.rb:280:inlog' activerecord (3.2.15) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in execute' activerecord (3.2.15) lib/active_record/connection_adapters/mysql2_adapter.rb:213:inexecute' activerecord (3.2.15) lib/active_record/connection_adapters/mysql2_adapter.rb:217:in exec_query' activerecord (3.2.15) lib/active_record/connection_adapters/mysql2_adapter.rb:226:inselect' slim_scrooge (1.0.14) lib/slim_scrooge/result_set.rb:29:in reload!' slim_scrooge (1.0.14) lib/slim_scrooge/monitored_hash.rb:32:innew_column_access' slim_scrooge (1.0.14) lib/slim_scrooge/monitored_hash.rb:19:in `block in []'

bhushangahire avatar Apr 28 '15 18:04 bhushangahire

Clearly something wrong with the sql statement - this isn't maintained any longer, but please feel free to fork / fix.

sdsykes avatar Apr 29 '15 07:04 sdsykes

SQl statement is built wrong as its putting 174 id in quote like '174' any pointers where to update the SQL generation would be good I can update the code then.

bhushangahire avatar Apr 30 '15 15:04 bhushangahire