GithubHelp home page GithubHelp logo

Comments (5)

jodosha avatar jodosha commented on June 9, 2024

@danelowe Hello, I'm sorry about this poor experience. I've just merged a PR that fixes this problem

In your case, it will return:

form = Admin::Forms::Job::Search.new(filter: {customer_name: 'Buster'})
form.to_h # => { :filter => { :customer_name => "Buster" }}

Please let me know if it still doesn't work for you. Thanks.

from validations.

danelowe avatar danelowe commented on June 9, 2024

Hey @jodosha Thanks so much for looking into this. It seems to work, but it also seems another regression may have been introduced?

require 'lotus/validations'
class Form
  include Lotus::Validations
  attribute :tags, type: Array
end
form = Form.new(tags: [:te, :st])
form.to_h

lib/lotus/utils/hash.rb:31:in 'to_h': wrong element type Symbol at 0 (expected array) (TypeError)

I guess it comes from Lotus::Utils::Attributes#_read_attribute.

If the value is an array, it responds to to_h, but will raise an error unless the array happens to be in the right 'format' for converting to a hash.

from validations.

jodosha avatar jodosha commented on June 9, 2024

@danelowe Sorry, you're right. 😿 That's because latest versions of Ruby have introduced Array#to_h. Fix is on the way.

from validations.

jodosha avatar jodosha commented on June 9, 2024

@danelowe Can you please try again with master? Thank you and sorry again for the troubles.

from validations.

danelowe avatar danelowe commented on June 9, 2024

@jodosha My tests are now passing 🎉 thanks!

from validations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.