4 ms·
Wow. These are STELLAR improvements! Check out the release notes here: https://github.com/rails/rails/blob/master/guides/source/4_1_release_notes.md https://git
by whalesalad 13y ago
Wow. These are STELLAR improvements! Check out the release notes here: https://github.com/rails/rails/blob/master/guides/source/4_1_release_notes.md https://github.com/rails/rails/blob/master/guides/source/4_1...
So excited about all of it. Native enum is a blessing.
Took me a while to figure it out but here is the required line for your Gemfile:
gem 'rails', '4.0.1.beta1'
# This works too, but isn't required (thanks to cantoniodasilva's comment below)
# gem 'rails', github: 'rails/rails', tag: 'v4.1.0.beta1'
Booya! Very excited to put it through the paces of this new app I am working on.
- cantoniodasilva 13y agoYou should be able to point the gem to '4.1.0.beta1' too, instead of relying on the git tag.
- whalesalad 13y agoGood to know, thanks. Note to the Rails team: might want to add this to your blog post and/or release notes? Perhaps I am the only person in the world who did not realize this would work. #noob
- chancancode 13y agoWe pushed a build to RubyGems.org[1], so you should be able drop the github option now: gem 'rails', '4.1.0.beta1' We upgraded a few apps in our local Ruby meetup group lately[2], and it's worth mentioning that you might need to upgrade the following gems too: gem 'rspec', '~> 3.0.0.beta1' gem 'rspec-rails', '~> 3.0.0.beta1' gem 'capybara', '~> 2.2.0' gem 'jquery-rails', github: 'takkanm/jquery-rails', branch:' fix_action_view_require' (I'm not 100% sure about the last one, might have been fixed since I last checked) I'll try to write this up in another blog post tomorrow. [1]: http://rubygems.org/gems/rails/versions/4.1.0.beta1 http://rubygems.org/gems/rails/versions/4.1.0.beta1 [2]: http://www.meetup.com/vancouver-ruby/messages/61805312/ http://www.meetup.com/vancouver-ruby/messages/61805312/ Edit: minor formatting fixes
- jenseng 13y agoIt's a shame these aren't actual database ENUMs, but rather ints (with the mapping in ruby land): https://github.com/rails/rails/commit/db41eb8a6ea88b854bf5cd11070ea4245e1639c5 https://github.com/rails/rails/commit/db41eb8a6ea88b854bf5cd... Even a text column would be preferable IMO ... you wouldn't need to worry about remapping if a value got removed, it's more easily queryable, and it's certainly more legible if you're looking at raw data (say, via psql). Plus you probably won't really save much (any?) space with an (64-bit) int.
- whalesalad 13y agoI agree with all of your points, but I don't think it's a shame. It's an awesome contribution and will make my work a lot easier on future projects. I'm personally going to try and take a stab at implementing this with strings versus ints though, since I agree you don't really save much by using the int and it's much friendlier for debug and future changes.
- yxhuvud 13y agoConsidering the sad state of mysql enums with the pitfalls it have, it really isn't a shame. I totally agree that a text column would have been preferable though.
- masklinn 13y agoShouldn't the mapping to database be backend-dependent anyway? SQLite has more or less no feature, yet ORMs don't feel the need to restrict themselves to what sqlite can do. (nota: oracle and mssql don't, afaik, have an enum type either) (and in Postgres, enum is not a type, it's a type constructor. First you have to `CREATE TYPE yourtype AS ENUM ( values... )` then you can use `yourtype` in a table, you can't have a column of type `ENUM ( whatever )` because Postgres enums are disjoint and not structurally equivalent)
- dwaltrip 13y agoYou can specify a smaller int size, I used 2-byte ints fairly often. Saves a good amount of space. This also makes it really easy to change the corresponding name of a value/categorization (no migration needed).