<ih8u>
well i'm not using rails, either, hence my question
infinityfye has joined #ruby
dionysus69 has joined #ruby
msv has quit [Ping timeout: 248 seconds]
msv has joined #ruby
TomyWork has joined #ruby
Linux_Kerio has joined #ruby
grenierm has quit [Ping timeout: 272 seconds]
inline has quit [Remote host closed the connection]
inline has joined #ruby
inline has quit [Remote host closed the connection]
inline has joined #ruby
brw has quit [Ping timeout: 268 seconds]
gr33n7007h has quit [Read error: Connection reset by peer]
gr33n7007h has joined #ruby
brw has joined #ruby
pages has quit [Ping timeout: 252 seconds]
jmcgnh has quit [Excess Flood]
mange has quit [Quit: Zzz...]
jmcgnh has joined #ruby
jmcantrell has joined #ruby
gr33n7007h has quit [Ping timeout: 268 seconds]
gr33n7007h has joined #ruby
inline has quit [Ping timeout: 252 seconds]
eddof13 has joined #ruby
inline has joined #ruby
wbooze has joined #ruby
eddof13 has quit [Ping timeout: 272 seconds]
jmcantrell has quit [Ping timeout: 276 seconds]
pages has joined #ruby
jmcantrell has joined #ruby
jmcantrell has quit [Ping timeout: 276 seconds]
<havenwood>
ih8u: I've used rack-attack with a few types of Rack apps like Roda but not without redis or memcached (supports dalli too).
<havenwood>
ih8u: I haven't used it, and it's a lot younger project, but zenspider has been working on a SQLite-backed tool called Bandit. https://github.com/zenspider/bandit#readme
Fusl has quit [Changing host]
Fusl has joined #ruby
<The_Camel_>
Bandit lol
Fusl has quit [Quit: K-Lined]
Fusl has joined #ruby
Fusl has quit [Client Quit]
Fusl has joined #ruby
<o0x1eef>
Nice project
oznek has joined #ruby
oznek has quit [Client Quit]
cappy has joined #ruby
<The_Camel_>
o0x1eef, say, do you think it's abnormal to have multiple ViewModels per view?
<The_Camel_>
I "can" do it. I just wonder if it's done by convention.
<The_Camel_>
Let's just say I extract repository models multiple times and I don't want to make a "God" object/singleton with all the information in one viewmodel
<The_Camel_>
so I was wondering if I can nicely and separately have multiple viewmodels.
cappy has left #ruby [#ruby]
<havenwood>
The_Camel_: In Rails, the traditional way was decorators (hand rolled or Draper) but these days ViewComponent is gaining popularity.
<havenwood>
The_Camel_: In practice, many Rails folk use partials. In Roda you might use partials, or a gem like Dry-View, or roll your own decorator, service object or component system.
<The_Camel_>
I think we might be talking of different things or I may be wrong.
<The_Camel_>
here's what I mean and here's how I do it in ASP-Core
<The_Camel_>
--------
<The_Camel_>
var albums_dir_content = _service.GetAllAlbumsDirectoryContent();
<The_Camel_>
var albums_metadata = _service.GetAllAlbumsMetadata();
<The_Camel_>
var albums_viewmodel = new AlbumsViewModel(albums_dir_content, albums_metadata);
<The_Camel_>
return View(albums_viewmodel);
<The_Camel_>
the question was
<The_Camel_>
can I have multiple viewmodels. like, let's say here I wanted to render on the same page, not just albums
<The_Camel_>
but do
<The_Camel_>
var movies_viewmodel = new ...
<The_Camel_>
and then
<havenwood>
We don't do ViewModels in Ruby, so I'm not clear if you mean in ASP?
<havenwood>
A ViewComponent is more tightly integrated with rendering.
<The_Camel_>
havenwood, the @binding which is exposed to an ERB template is essentially a viewmodel. and you can have multiple @bindings available to the template after.
<The_Camel_>
but ok I see.
<havenwood>
The_Camel_: A decorator, like Draper-style is probably more akin to what you're thinking.
<havenwood>
Still, there are some differences. A decorator is a thinner veil.
<The_Camel_>
havenwood, I'll have a look at how decorators are done then.
<havenwood>
Some folk may use a Service object as a ViewModel type thing.
<havenwood>
The_Camel_: Check out Draper.
dionysus69 has quit [Ping timeout: 248 seconds]
<havenwood>
The_Camel_: Or with Ruby it's actually not much code to roll your own. I've done that before.
<havenwood>
If you don't need the fancy Draper features you can set up your own delegator.
<havenwood>
Or ViewComponent has come into favor in Rails land. I'd not use it in Sinatra or Roda since it's integrated.
<havenwood>
The_Camel_: An aside, but Phoenix has a really nice way to cognize this layer overlayed on the Repo pattern.
<The_Camel_>
right.
<havenwood>
They introduced Context with context functions, maybe more akin to what you're thinking with ViewModel from ASP.
<havenwood>
In a functional style.
<havenwood>
TL;DR: Many, many ways to do it, but we don't quite use ModelView pattern in Ruby frameworks at least I haven't run into it myself.
schne1der has quit [Ping timeout: 276 seconds]
<The_Camel_>
havenwood, yes, well, that's because ruby prefers to just define the viewmodel directly in a variable right in the controller, often in json-style syntax and @bind it immediatelly
<The_Camel_>
but it's there. just because it's not called a viewmodel or because you don't extract it nicely into another file, doesn't mean the "pattern" isn't there.
<The_Camel_>
anyway, I will check those libraries out because I do
<The_Camel_>
like
<The_Camel_>
to keep my viewmodels separate.
<o0x1eef>
I personally wouldn't let a pattern dictate what I can and can't do. Whether movies can appear alongside books is a product decision. Most of the time it is enough to keep it simple and practical. Then you don't need to reach for complex concepts or patterns. Sometimes that's just making life more complicated.
<havenwood>
The_Camel_: In Rails land, helpers handle the functional view stuff and decorators (draper) handle the model-specific decoration typically.
<The_Camel_>
I agree. Though I have found that sticking to patterns often leads to very pleasant code and less unpleasant "oh shit, something went wrong".
<havenwood>
The_Camel_: Or ViewComponent might even be added to Rails, since it more tightly integrates and gives Rails niceties by convention.
<The_Camel_>
@o0x1eef*
<The_Camel_>
and I like my code looking pleasant.
<havenwood>
If we're talking Rails, I'd stick closely to "on the Rails" what it ships with plus ViewComponent.
<havenwood>
If we're talking Roda, I'd use plugins and probably forgo any gems — even Dry-View.
<The_Camel_>
havenwood, mhm. I have to check ActionPack or whatever it was called.
<hombrelaser>
Oh hi, talking about rails, I've been dabbling on action text and found out I could save rich text directly on a column instead of using has_rich_text. I'm aware that doing this deprives me of attachments and any methods the RichText models have, but outside of that, are there any security implications on this? I found nothing conclusive on the actiontext source, docs or trix's
<The_Camel_>
havenwood, spring btw has a dynamic viewmodel. you can directly define it as:
<havenwood>
The_Camel_: Yeah, it's actually pretty cool to make your own Active Model thing and use the modular stuff that makes it "magically" work nice with Action View etc. I gave a wrapping an API with Active Model (for things other than Active Record databases) but wish I'd given examples of wrapping a file store or stuff other than an API.
<o0x1eef>
My favorite Rails feature is probably ActiveRecord. That's what I usually carry over to non-Rails projects.
<The_Camel_>
o0x1eef, so an ORM framework.
<The_Camel_>
it does indeed pay off to skip SQL
<The_Camel_>
SQL is a bitch.
<havenwood>
hombrelaser: I haven't done it so haven't researched but I'd assume you'd need to at a minimum sanitize and maybe limit to ActionText allowed tags and attributes.
<o0x1eef>
I don't mind SQLL but ActiveRecord (and any good ORM) works at a higher level of abstraction so you can think about your data as objects
<The_Camel_>
o0x1eef, yup. i like that too.
<The_Camel_>
o0x1eef, though I do dislike
<The_Camel_>
o0x1eef, doing the validation and whatever else needed for
<The_Camel_>
setting up an ORM object ready for ORM use.
<The_Camel_>
o0x1eef, relationships too.
<The_Camel_>
I know they're mandatory but
<The_Camel_>
meh.
<The_Camel_>
I FEEL, like it could be done without.
<The_Camel_>
but nobody cares what I "feel".
<o0x1eef>
I feel happy
<havenwood>
homeb, ah they left. Though looks like ActionText just uses sanitize? Would have to look at internals if it's not plainly documented.
<The_Camel_>
:)
<o0x1eef>
Because code-server works, at last
<o0x1eef>
Long slog but so worth it
<havenwood>
The_Camel_: In Ruby I'd recommend trying Roda + Sequel and Rails.
<havenwood>
I wish I could say Hanami for the latter but Rails is still pretty nice.
<The_Camel_>
havenwood, I remember. I will look into Roda. but right now, I kicked ruby in the balls in favour for something nicer - Oracle and Microsoft.
<havenwood>
Both Roda and Sequel having a plugin system really lets you compose the framework you want. Pretty nifty, and I really like it for APIs.
<The_Camel_>
never been happier in my entire life.
<havenwood>
The_Camel_: Eww. At least consider Elixir and Phoenix. They're quite nice.'
<o0x1eef>
I bet The_Camel_ is wearing a suit and tie typing this stuff
<The_Camel_>
havenwood, I'll check it out. but right now, having seen what Microsoft/Oracle provides, everything else in my eyes is a toy lol
<The_Camel_>
makes me wanna burn those motherfuckers down lol
<havenwood>
The_Camel_: Try describing your app to phoenix.new and magically having lovely, functional Elixir code.
<havenwood>
We live in the future...
<havenwood>
Not just code, running in prod.
<The_Camel_>
havenwood, looks like Github Copilot alternative.
<havenwood>
The_Camel_: It knows Phoenix and Elixir well and runs the apps for you immediately.
<havenwood>
Fly.io backed.
<The_Camel_>
that's always nice.
<havenwood>
I haven't used it for anything but watched Chris McCord talking about it and it seems... impressive.
<havenwood>
And I like having a Phoenix app as something I can switch to working on myself.
<The_Camel_>
havenwood, I read that "Ship" word in fly.io and I got a twitch in my eye remembering that philosophy of "Just Ship It."
<havenwood>
Lovely framework. Inspired by Rails.
<havenwood>
🚢
<The_Camel_>
ﷲ
<havenwood>
The_Camel_: If you yearn for Java/.NET-style tooling with something a tad more modern, either Rust or get a mac and Swift. Or if you sadly just want to get things done devoid of joy, there's Golang. ;)
<havenwood>
Any Golang API I just feel the constant urge to port it to Elixir.
<The_Camel_>
havenwood, /me puts on a suit and tie while writing .NET code.
<havenwood>
The_Camel_: Put on a suit and tie and write Rust. Or Zig if you're a perfectionist and like C interop.
<havenwood>
Comptime is nifty. From D I think?
<The_Camel_>
Chicks love D I guess.
<havenwood>
Boo
<havenwood>
I just can't get into Zig.
<The_Camel_>
I have a friend that does zig and he praises it to me everyday.
<havenwood>
Seems early but impressive what all is already being built with it. Kinda glad the YJIT/ZJIT folk felt Zig was too early since easier for me to follow the Rust.
<havenwood>
Java and .NET don't even flash across my minds as options to consider. Surreal they're still being used broadly.
<havenwood>
Seem half the "Java" shops are really using Kotlin. ;)
<The_Camel_>
havenwood, surreal?
<havenwood>
The_Camel_: Like a parallel odd world.
<havenwood>
The_Camel_: On the JVM I'd use Clojure or JRuby/TruffleRuby.
<The_Camel_>
havenwood, I dunno, I've done web development in django, flask, pyramid, sinatra, rails and yesod.
<havenwood>
Actually pretty fun how easy it is to do stuff like use Clojure STM from JRuby.
<havenwood>
Just a few lines of code.
<The_Camel_>
I've been slightly unsatisfied with everything except sinatra. until I went to Java/.NET
<The_Camel_>
now I don't want to see anything else lol
<havenwood>
The_Camel_: Like using regular Java with Spring style?
<havenwood>
Not even Kotlin?
<The_Camel_>
havenwood, yes.
<The_Camel_>
not even gradle either.
<havenwood>
But... why?
<The_Camel_>
plain old maven.
<The_Camel_>
havenwood, because it's expectable code that lets me focus on what I want to build rather than bother with the tooling.
<The_Camel_>
I don't care about the tool half the tiime.
<The_Camel_>
havenwood, doesn't have type checking. bleh.
<havenwood>
.NET I don't even. I can see it if you're building native Windows apps, I guess? For the web, gah.
<The_Camel_>
the
<havenwood>
The_Camel_: I could follow what you're saying if Golang and Rust didn't exist with tier 1 support.
<The_Camel_>
12GB IDE does bother me.
<The_Camel_>
but
<The_Camel_>
not enough to care.
<havenwood>
It's just Java and .NET are old tech and the folk who made 'em are writing Rust.
<The_Camel_>
havenwood, yeah but golang and rust don't have IDEs that are free.
<havenwood>
I shouldn't troll. ;)
<The_Camel_>
I've nothing against rust. heck, I'd do some of it. IF it came with an IDE.
<havenwood>
The_Camel_: VS Code or Helix out of the box have pretty amazing IDEs.
<hombrelaser>
havenwood: oh, it makes sense if I'm not using the rich text model to have to sanitize the input myself.
<havenwood>
At least I find the Rust integration pretty jaw dropping.
<o0x1eef>
Helix doesn't support plugins though. That was a deal breaker for me.
<havenwood>
o0x1eef: neovim ftw
<o0x1eef>
code server where it's at :D
<havenwood>
o0x1eef: I just figure if the camel doesn't want to install an extension then a plugin is out. Haha.
<o0x1eef>
:D
<The_Camel_>
If there's no IDE I can slap in and start coding without me having to install plugins or set up some conundrum
<havenwood>
The_Camel_: I'd be curious what you'd think of VS Code with Rust extension installed?
<The_Camel_>
I will start making camel noises.
<The_Camel_>
havenwood, probably doesn't work, that's the first thing that comes to mind. I'd have to tickle it until it orgasms in some VS code settings and PATH properties and install another plugin because the first one doesn't work and so on.
<havenwood>
The_Camel_: In my experience, full-fledged IDEs have pretty large plugins and extension that automatically install similar to starting a Rust project in VS Code, but actually a lot less heavy feeling.
<havenwood>
The_Camel_: I literally just installed VS Code and Rust extension just now with Homebrew and they work.
<havenwood>
Zero configuration, just works.
<The_Camel_>
probably because you're on a Mac and not on Window.
<The_Camel_>
s
<havenwood>
I am indeed.
<The_Camel_>
yeah, try windows.
<The_Camel_>
then we'll talk :P
<havenwood>
Is VS Code support on Windows no good? Or rustup doesn't work?
<havenwood>
Did you install Rust with rustup?
<havenwood>
I'm having trouble imaging what went wrong.
<havenwood>
Seems like it should *just work*.
<The_Camel_>
I dunno but I tried to install Ruby LSP and I shoved my ... in it after an hour.
<The_Camel_>
even chatGPT didn't know what else to do.
<havenwood>
The_Camel_: 1) Install Rustup from PowerShell, 2) Install VS Code, 3) ..., 4) Profit.
<The_Camel_>
you mean the errors that come in a tuple alongside the return values?
weaksauce has joined #ruby
<havenwood>
The_Camel_: More the error message being for humans. Says what went wrong. Shows where. Suggests what you might have meant. Links to the docs.