Skip to content

Assigning numerical values #17

Description

@kostia

Hello,

there is no automatically parsing on assigning numerical values yet.

Following works in ActiveRecord:

class Company < ActiveRecord::Base
  attr_accessible :sort_key
end

c = Company.new
c.attributes = {sort_key: '13'}
c.sort_key #=> 13
c.sort_key.class #=> Fixnum

Which doesn't yet work in `Elastictastic':

class Company
  include Elastictastic::Document
  field :sort_key, type: :integer
end

c = Company.new
c.attributes = {sort_key: '13'}
c.sort_key #=> '13'
c.sort_key.class #=> String

That makes it really unhandy to assign numerical values from request params (for even integer values are submitted as strings).

Would be great if it would work!

Thanx!
Kostia

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions