Git Product home page Git Product logo

Comments (11)

spohlenz avatar spohlenz commented on June 8, 2024

Are you seeing this behavior on the main branch? This should theoretically be fixed by 55963f5 but I haven't made a new release containing that fix yet.

from trestle.

jonmchan avatar jonmchan commented on June 8, 2024

I haven't tried on main branch yet, I'll give it a shot.

from trestle.

jonmchan avatar jonmchan commented on June 8, 2024

no go:

irb(main):008:0> Response.find(5).response_state
  Response Load (0.6ms)  SELECT "responses".* FROM "responses" WHERE "responses"."id" = $1 LIMIT $2  [["id", 5], ["LIMIT", 1]]
=> "sent"   

image

GIT
  remote: https://github.com/TrestleAdmin/trestle.git
  revision: d89b3b8550879f24faa6a9510f072a3337a0bb38
  branch: main
  specs:
    trestle (0.9.8)
      activemodel (>= 5.2.0)
      kaminari (>= 1.1.0)
      railties (>= 5.2.0)
      sprockets-rails (>= 2.0.0)

from trestle.

spohlenz avatar spohlenz commented on June 8, 2024

How are you declaring the enum in your model?

In my testing, I've been testing for three types of declarations:

  1. String backed enum with a hash declaration:
    enum status: { draft: "Draft", published: "Published", junk: "Junk" }

  2. Integer backed enum with an array declaration:
    enum status: %w(draft published junk)

  3. Integer backed enum with a hash declaration:
    enum status: { draft: 0, automated: 1, mixed: 2 }

These all behave correctly in my own testing, but perhaps I've missed another option.

To cover all bases, could you also please let me know your Rails (and Ruby) versions?

from trestle.

jonmchan avatar jonmchan commented on June 8, 2024

I am defining it like this:

  enum response_state: {
    created: 0,
    awaiting_agent_input: 10,
    rejected_by_agent: 90,
    sent: 100
  }
root@a3a68b4ee119:/app# bin/rails -v
Rails 6.1.6
root@a3a68b4ee119:/app# ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]

Thanks for investigating into this - I thought everyone had this issue.

from trestle.

spohlenz avatar spohlenz commented on June 8, 2024

I'm at a bit of loss -- I've created a fresh Rails 6.1.6 app which matches your setup (as far as I can tell) and it works for me.

I've pushed the repo up to https://github.com/spohlenz/TrestleEnums-jonmchan. Perhaps you might be able to trace the commits to see where things might differ within your app.

from trestle.

jonmchan avatar jonmchan commented on June 8, 2024

Let me look through my application and see if I have anything custom installed. This is certainly puzzling!

from trestle.

jonmchan avatar jonmchan commented on June 8, 2024

Just to double check, I checked out your example and ran it locally, it worked as expected.

image

I did notice on my project, it is rendering the table column as string and not the box:

image

vs yours:

image

Is this indicative of anything?

The only other difference I see is your version is using sqlite. I'm going to try switching your project to postgres and see if it breaks.

from trestle.

jonmchan avatar jonmchan commented on June 8, 2024

switched the example project to pg, still works... so it isn't PG... I'll continue investigating into this.

from trestle.

jonmchan avatar jonmchan commented on June 8, 2024

Got it working in my project! It's a bit embarrassing, but I may have not restarted my rails server when switching to the github branch. The latest changes does indeed fix this issue.

image

from trestle.

spohlenz avatar spohlenz commented on June 8, 2024

Thanks for the update. Glad to hear it's all sorted!

from trestle.

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.