Comments (11)
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.
I haven't tried on main branch yet, I'll give it a shot.
from trestle.
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"
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.
How are you declaring the enum in your model?
In my testing, I've been testing for three types of declarations:
-
String backed enum with a hash declaration:
enum status: { draft: "Draft", published: "Published", junk: "Junk" }
-
Integer backed enum with an array declaration:
enum status: %w(draft published junk)
-
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.
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.
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.
Let me look through my application and see if I have anything custom installed. This is certainly puzzling!
from trestle.
Just to double check, I checked out your example and ran it locally, it worked as expected.
I did notice on my project, it is rendering the table column as string and not the box:
vs yours:
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.
switched the example project to pg, still works... so it isn't PG... I'll continue investigating into this.
from trestle.
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.
from trestle.
Thanks for the update. Glad to hear it's all sorted!
from trestle.
Related Issues (20)
- Changing date format HOT 3
- Option to disable form as "show" view? HOT 1
- My custom helper not is recognized HOT 2
- How i use concerns at trestle? HOT 1
- Remove Multiple Records From MODEL Page
- WebSockets / action_cable support? HOT 2
- Pagination for a custom index View
- Fix typo for Vietnamese locale HOT 1
- Direct upload or chunked file upload support? HOT 2
- Fails without sassc-rails
- Unable to locate favicon.ico in public folder HOT 1
- Best Way To Provide a Select Dropdown for belongs_to that is optional HOT 2
- Filter with a select list
- Errors on check_box fields not displaying HOT 2
- Customize navbar HOT 3
- Mongoid support HOT 2
- Use importmap in Trestle HOT 6
- Fix Brazilian Portuguese translation
- Refresh view/tabs under dialog after update/save HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trestle.