<cxl>
Hi all, with this controller and view: https://gist.github.com/coaxial/7f1a49ceb99578454239b55fa0fa245c, errors never show. once in the view, @errors is always nil even if it wasn't in the controller (checked with a breakpoint before the redirect). What am I doing wrong?
Tempesta has quit [Quit: See ya!]
Tempesta has joined #ruby
crankharder has joined #ruby
crankharder has quit [Ping timeout: 272 seconds]
<ox1eef_>
The redirect won't persist @errors to the next action.
<ox1eef_>
You might have to store them in 'flash'.
<ox1eef_>
cxl: ^
M1ll173r47[m]1 has quit [Ping timeout: 260 seconds]
andrea[m] has quit [Ping timeout: 260 seconds]
Bigou[m] has quit [Ping timeout: 252 seconds]
Cata[m]1 has quit [Ping timeout: 265 seconds]
flan[m] has quit [Ping timeout: 246 seconds]
tiziodcaio has quit [Ping timeout: 260 seconds]
jhass[m] has quit [Ping timeout: 260 seconds]
zaben[m]1 has quit [Ping timeout: 256 seconds]
Alhamdulillah[m] has quit [Ping timeout: 246 seconds]
M1ll173r47[m]1 has joined #ruby
tiziodcaio has joined #ruby
Bigou[m] has joined #ruby
andrea[m] has joined #ruby
Cata[m]1 has joined #ruby
flan[m] has joined #ruby
Sankalp has quit [Ping timeout: 260 seconds]
Sankalp has joined #ruby
jhass[m] has joined #ruby
zaben[m]1 has joined #ruby
Alhamdulillah[m] has joined #ruby
<cxl>
ox1eef_: I see, thanks. I'm trying to use a separate controller for my form, as users can upload several files at once but they should result in one model per file. Is there a reference somewhere for this pattern? I got it kinda working but it's hacky and I'm not super happy with it.
crankharder has joined #ruby
<ox1eef_>
cxl: Then you probably want to open a transaction, and make it an all or nothing operation. You could also only redirect on success, and otherwise re-render the form (with '@errors' in scope).
Jonopoly has joined #ruby
<ox1eef_>
I suggest that you create a class method on your model that accepts an array of files. This method should open a transaction (eg: transaction { .. }), and when you save each model, use save! - as that will raise an exception on error, and cause a DB rollback.
<ox1eef_>
You might have to adapt the situation a bit so that you can report back errors, and I guess you would want errors for each file, so in that case you should probably collect errors for each model, and at the very end raise to cause a rollback for any records that did save.
crankharder has quit [Ping timeout: 272 seconds]
moldorcoder7 has joined #ruby
crankharder has joined #ruby
caedmon has joined #ruby
crankharder has quit [Client Quit]
cartdrige has joined #ruby
caedmon has quit [Ping timeout: 272 seconds]
caedmon has joined #ruby
crax23 has joined #ruby
cartdrige has quit [Ping timeout: 246 seconds]
cartdrige has joined #ruby
crax23 has quit [Ping timeout: 264 seconds]
cartdrige has quit [Read error: Connection reset by peer]
cartdrige has joined #ruby
crax23 has joined #ruby
cartdrige has quit [Ping timeout: 272 seconds]
crax23 has quit [Client Quit]
Starfoxxes has quit [Ping timeout: 265 seconds]
Starfoxxes has joined #ruby
graywolf has joined #ruby
willfish has quit [Quit: WeeChat 3.7.1]
polishdub has joined #ruby
graywolf has quit [Quit: WeeChat 3.5]
Jonopoly has quit [Quit: WeeChat 3.0]
sylario has joined #ruby
stirl has joined #ruby
joto has joined #ruby
desnudopenguino has quit [Ping timeout: 246 seconds]
Al2O3 has quit [Ping timeout: 255 seconds]
desnudopenguino has joined #ruby
Al2O3 has joined #ruby
jidar has joined #ruby
reset has joined #ruby
r3m has quit [Quit: WeeChat 3.8-dev]
r3m has joined #ruby
_ht has joined #ruby
stirl has quit [Ping timeout: 260 seconds]
r3m has quit [Quit: WeeChat 3.8-dev]
r3m has joined #ruby
ur5us has joined #ruby
desnudopenguino has quit [Ping timeout: 256 seconds]
_ht has quit [Remote host closed the connection]
c10l has quit [Quit: See ya! o/]
c10l has joined #ruby
c10l has quit [Client Quit]
c10l has joined #ruby
ur5us has quit [Read error: Connection reset by peer]