<pandabot>
Learned new fact rubychanges; 451 facts total
caedmon has quit [Ping timeout: 272 seconds]
hansolo has quit [Remote host closed the connection]
hansolo has joined #ruby
graywolf has joined #ruby
caedmon has joined #ruby
caedmon has quit [Ping timeout: 268 seconds]
graywolf has quit [Quit: WeeChat 3.5]
caedmon has joined #ruby
Vonter has quit [Quit: WeeChat 3.7.1]
caedmon has quit [Ping timeout: 268 seconds]
Vonter has joined #ruby
c10l2 has joined #ruby
c10l has quit [Ping timeout: 268 seconds]
c10l2 is now known as c10l
caedmon has joined #ruby
ur5us_ has quit [Ping timeout: 260 seconds]
caedmon has quit [Ping timeout: 260 seconds]
caedmon has joined #ruby
caedmon has quit [Ping timeout: 272 seconds]
cryptkeeper has quit [Quit: Connection closed for inactivity]
otisolsen70 has joined #ruby
rvalue has quit [Remote host closed the connection]
rvalue has joined #ruby
moldorcoder7 has quit [Ping timeout: 252 seconds]
gr33n7001 has joined #ruby
gr33n7007h has quit [Killed (molybdenum.libera.chat (Nickname regained by services))]
gr33n7001 is now known as gr33n7007h
Guest202 has joined #ruby
teclator has joined #ruby
Y05hito__ has quit [Ping timeout: 272 seconds]
Y05hito__ has joined #ruby
crax23 has joined #ruby
Y05hito__ has quit [Ping timeout: 268 seconds]
crax23 has quit [Ping timeout: 272 seconds]
willfish has joined #ruby
konsolebox has joined #ruby
Rounin has joined #ruby
Rounin has quit [Changing host]
Rounin has joined #ruby
weaksauce has joined #ruby
weaksauc_ has quit [Ping timeout: 252 seconds]
tomtmym has joined #ruby
tomtmym has quit [Changing host]
tomtmym has joined #ruby
ur5us_ has joined #ruby
<cxl>
Hi all, I'm getting reacquainted with Rails and I'm wondering: how can I create a form that hits a particular controller and action without form_for @my_model? The reason being that I want the user to be able to upload multiple files in one go, but my underlying model represents each file separately; so it would be confusing to have form_for @my_model with more than one file, then loop over, then create each
<cxl>
model from each file.
TomyWork has joined #ruby
<jhass[m]>
cxl: Checkout the `from_with` helper, it takes either a model, a path, a scope or a combination thereof as needed
<jhass[m]>
It can also often make sense to create a dedicated ActiveModel::Model for your form, you don't have to use ActiveRecord models
tumdum has quit [Ping timeout: 255 seconds]
<cxl>
jhass[m]: I don't quite get your second sentence. Where could I learn more about this?
<cxl>
jhass[m]: so you mean having a specific model that is only for the form, and the action in that model's controller creates individual models from the file?
<jhass[m]>
Yes for example
<jhass[m]>
As an option. You can also just build model less forms with form_with and just dissect params manually
<jhass[m]>
form_with largely replaces form_for and form_tag
hightower3 has quit [Remote host closed the connection]
hightower3 has joined #ruby
willfish has quit [Ping timeout: 252 seconds]
hightower3 has quit [Remote host closed the connection]
hightower3 has joined #ruby
gr33n7007h has quit [Quit: WeeChat 3.7.1]
hightower3 has quit [Remote host closed the connection]
cxl has quit [Quit: bye]
Guest202 is now known as gr33n7007h
cxl has joined #ruby
cxl has quit [Quit: bye]
cxl has joined #ruby
<introom>
hi. what's `actable` in rails?
<jhass[m]>
Doesn't sound like a standard feature, it's probably coming from some gem
cxl has quit [Quit: bye]
cxl has joined #ruby
<introom>
from this file /ruby/gems/2.7.0/gems/active_record-acts_as-5.0.3/lib/active_record/acts_as/relation.rb
<introom>
right.
perrierjouet has quit [Quit: WeeChat 3.7.1]
<introom>
thanks for the hint
cxl has quit [Quit: bye]
willfish has joined #ruby
cxl has joined #ruby
cartdrige has joined #ruby
eron has joined #ruby
moldorcoder7 has joined #ruby
crax23 has joined #ruby
cartdrige has quit [Ping timeout: 252 seconds]
Laplace has joined #ruby
<Laplace>
Can a module add/update class attributes and instance attributes when it is included?
crax23 has quit [Ping timeout: 272 seconds]
Pixi` has joined #ruby
Pixi has quit [Ping timeout: 252 seconds]
cartdrige has joined #ruby
dionysus69 has quit [Ping timeout: 252 seconds]
dza has quit [Remote host closed the connection]
dza has joined #ruby
willfish has quit [Ping timeout: 268 seconds]
perrierjouet has joined #ruby
desnudopenguino has quit [Quit: desnudopenguino]
eddof13 has joined #ruby
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #ruby
<havenwood>
Laplace: Yes, it can for the class or module it's included in.
<havenwood>
Here's an example:
<havenwood>
module Meaning def self.included(mod) = mod.instance_variable_set(:@meaning, 42) end
<Laplace>
havenwood: Yeah I think I managed to do it using class_variable_set
<Laplace>
base.class_variable_set(...)
<havenwood>
module Wombat; include Meaning; def self.meaning = @meaning end
<havenwood>
Wombat.meaning #=> 42
crax23 has joined #ruby
<havenwood>
Laplace: Class variables are generally frowned upon these days and Matz considers them soft deprecated but won't remove them since it'd break code.
<havenwood>
We should really update the class variable documentation to reflect that status quo...
<Laplace>
Is there a different way to do this? I am trying to make a module which when is included (or extended, I am indifferent) it creates a dictionary to store metadata
cartdrige has quit [Ping timeout: 260 seconds]
<havenwood>
Laplace: I don't quite follow from that but I bet folk here could give recommendations if the code is shareable.
<Laplace>
Here's a working example using class_variable_set, would love to know if there is a better way to do it https://pastebin.com/RcSemKZR (even a few pointers are fine)
<ruby[bot]>
Laplace: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<havenwood>
Laplace: On first glance, looks like an instance variable would suffice. It's pretty normal to swap out old class variables for instance variables that can do the same thing.
<Laplace>
I don't want the schema here to be created/recomputed per instance though
<havenwood>
Check my example above. It's an instance variable on the class itself not an instance of the class.
<havenwood>
I show a module, but it works the same for a class.
_aeris_ has joined #ruby
<havenwood>
If I'm just missing the problem, say a bit more about why an instance variable on the class doesn't work?
moldorcoder7 has quit [Ping timeout: 260 seconds]
aeris has quit [Ping timeout: 255 seconds]
_aeris_ is now known as aeris
moldorcoder7 has joined #ruby
<havenwood>
Usually, instance variables are used inside a method and are scoped to the instance of the class. You can also define instance variables at the top level of a class, where they'll be available to the class itself not instances of the class.
<havenwood>
Unless I'm missing something, you can just swap to `instance_variable_set` and otherwise use this the same.
<havenwood>
I'm assuming you'll then mutate this value, but you could alternatively set a CONSTANT variable default.
<havenwood>
If you're not mutating it, use a CONSTANT rather than @instance_variable.
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
crax23 has joined #ruby
cartdrige has quit [Ping timeout: 272 seconds]
dionysus69 has quit [Ping timeout: 260 seconds]
otisolsen70 has quit [Quit: Leaving]
_ht has quit [Quit: _ht]
<isene>
adam12: Thank you for all the help. I have now pushed a working gem for XRPN. I manouvered back and forth until I landed on a working (and simple) way of handling my requirements. Thank you for the levelling up of my knowledge.
<isene>
ox1eef_: ^^^ you too.
<adam12>
isene: yw!
Sankalp has quit [Ping timeout: 260 seconds]
Sankalp has joined #ruby
<joto>
isene well done
crax23 has quit [Quit: Leaving]
ox1eef_ has quit [Ping timeout: 265 seconds]
John_Ivan has joined #ruby
brw has joined #ruby
ruby[bot] has quit [Remote host closed the connection]