kemalyst / kemalyst-generator

Rails like command line for Kemalyst
MIT License
12 stars 2 forks source link

Variable type conversions for fields should probably happen in model instead of controller. #37

Closed elorest closed 7 years ago

elorest commented 7 years ago

https://github.com/TechMagister/kemalyst-generator/blob/master/src/templates/scaffold/src/controllers/%7B%7Bname%7D%7D_controller.cr.ecr#L30

I feel like this logic should be move the to model. What are your thoughts?

drujensen commented 7 years ago

It's a tempting proposition but then you would need to have something like params.require().permit() type logic to avoid mass assignment issues.

The logic of determining which fields should be updated should reside here. How that is done, I'm open to solutions.

elorest commented 7 years ago

I agree that the logic for what params are saved should be in the controller. Similar to strong params. In the past. Rails 3.1 and earlier it actually was in the model but I prefer it in the controller. I think that the type conversions should be done in the model though. For instance person.age should be able to take a (String | Int32 | Int64 | Float32 | Nil) etc and convert to the the appropriate thing. After all we're having to query it to figure out what the field types should be in the first place.

Isaac Sloan - isaacsloan.com Artisan Rails Architect 1391 S Slate Canyon Dr. Provo, Ut 84606 Cell: (435)-669-5005

On Sun, Apr 16, 2017 at 7:33 PM, Dru Jensen notifications@github.com wrote:

It's a tempting proposition but then you would need to have something like params.require().permit() type logic to avoid mass assignment issues.

The logic of determining which fields should be updated should reside here. How that is done, I'm open to solutions.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TechMagister/kemalyst-generator/issues/37#issuecomment-294387222, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHmpEzya09WCcA3rh_4pKiMa1FFKt7Mks5rwsF8gaJpZM4M-yn9 .

drujensen commented 7 years ago

Aaah, your talking about the type conversion. So the setter will be smart enough to convert it to the appropriate type? That is an excellent idea.

elorest commented 7 years ago

Yeah exactly. I guess I should have worded that better. Sorry. Are you going to the Crystal code camp?

On Apr 16, 2017 7:52 PM, "Dru Jensen" notifications@github.com wrote:

Aaah, your talking about the type conversion. So the setter will be smart enough to convert it to the appropriate type? That is an excellent idea.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TechMagister/kemalyst-generator/issues/37#issuecomment-294388845, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHmpMHqZoFmUgY53adiCfIOYInCmnpPks5rwsXVgaJpZM4M-yn9 .

drujensen commented 7 years ago

I wish. :-( I would love to meet the community.

I fell in love with Crystal a year ago and I was looking for a rails like framework. I started contributing to Amethyst and created an ORM for it. Unfortunately, Amethyst's creator stopped working on it, so I moved to contribute to kemal. However, the kemal team is focused on speed and less on providing a rails like framework.

I decided to fork kemal and add handlers for session, flash, etc., and rewrote the router to allow you to chain HTTP::Handlers in the routes instead of using before callbacks like kemal.

The ORM has been through many iteration. I removed my custom migrations in favor of micrate, moved to use the Crystal::DB drivers, and contributed to fez to provide a generator.

TechMagister started working on kgen and added the watch and console commands. These are really useful and make a huge difference when developing. Others have started contributing and it is growing. There is even an i18n handler.

A couple of other features I would love to add are back-end ActionCable compatible support and background jobs with sidekiq for crystal.

I am doing a presentation here at OCRuby in Southern California in a couple weeks. I'm extremely happy to see your going to present this at RailsConf. Maybe we can compare notes.

elorest commented 7 years ago

Nice I've been writing Ruby/Rails for 12 years, but Crystal became my new passion about a year ago too. I wrote the vim plugin for slang, and started working on scaffolding in fez last July but never ended up committing it to the Jeremy switched the templating engine. We've had multiple talks on crystal at both Utah Valley RB and Salt Lake City Ruby. I'm frustrated by everyone switching to elixir so I'm doing what I can to move them to crystal instead. I still love ruby but I'm really impressed by crystal. Even matz the creator of ruby donated money via bountysource so apparently he's impressed too.

I'm currently working on writing an experimental Infotainment system in crystal for trucks at [https://nikolamotor.com](Nikola Motor Company). So far it compares quite nicely with the one in qt and hasn't taken as long to build.

Before I present next week I'll record a video walkthrough to make sure I get it right and I'll send it along to you.

elorest commented 7 years ago

I don't really have the time to go to the codecamp but decide just to do it so I bought all my tickets last week.

drujensen commented 7 years ago

I'm jealous your working with Crystal. That Nikola truck looks badass! I am also frustrated by the move to elixir. I spent a couple hours learning it and wasn't convinced. Maybe I didn't give it enough time? It's hard looking at other languages. I've been spoiled working with Ruby.

elorest commented 7 years ago

I've spent close to a week playing with Elixir and Phoenix. I think I'd rather go back to C if we're switching back to functional. It reminds me of college before we learned about OOP. I guess hipsters love film camera's, functional programming and deploying through ftp.

drujensen commented 7 years ago

I'm going to install your vim-slang plugin. didn't realize it existed. 👍

elorest commented 7 years ago

I added css: and javascript: block tags to slang a couple weeks ago so slang should be pretty close to parity with slim now.

On Apr 16, 2017 10:56 PM, "Dru Jensen" notifications@github.com wrote:

I'm going to install your vim-slang plugin. didn't realize it existed. 👍

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TechMagister/kemalyst-generator/issues/37#issuecomment-294405043, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHmpFJQsTaCsxynrc9OyP1tamE3p-H0ks5rwvDvgaJpZM4M-yn9 .