<Pika>
this seems to imply that there's an _insert_attributes method I can use to add attributes but when I call ._insert_attribute({ key: "value"}) I just get an error stack level too deep.
<phaul>
RIP Jim
<phaul>
idk, this code might not be compatible with more recent MRIs
<phaul>
there was a talk he made on xmlbuilder.. btw. which is worth watching.. it's on youtube
<phaul>
but I don't believe the code is maintained
<leftylink>
interesting
<leftylink>
I was about to say that order is only necessary in the world where hashes are unordered, but I guess the hash could also be ordered but in the wrong order that you don't want it
<lmat>
I'm using rails with minitest. I'm writing an integration test for my controller. When I call nearly any action on my controller, it checks to see if the current user is logged in. How do I get my test logged in?
Inline has quit [Quit: Leaving]
<lmat>
I'm hoping there's something super simple like login user; but this will have to get into the session state (?) which isn't available during unit tests (?)
<Pika>
wait WHAT
<Pika>
this guy is no longer with us?
<Pika>
is this why people use the nekogiri builder?
<Pika>
Does the nekogiri builder even have a way to add attributes after the fact?
<Pika>
*nokogiri =X
davidw has joined #ruby
<Pika>
My issue is also that I'm on ruby 2.33 and I think the nokogiri requires 2.4?
<phaul>
We got so much briliant stuff from him. rake for instance
<havenwood>
lmat: Consider writing a test helper for #logged_in? if you're doing your own auth.
<havenwood>
lmat: Maybe something like: def logged_i?; if integration_test?; !!controller.current_user if controller.respond_to? :current_user; else; !session[:user_id].nil?; end; end
<Pika>
damn... that's really sad :{
<adam12>
We lost a lot of great Rubyists over the last 10 years :\ Ezra, Jim, James Golick, Prakash off the top of my head. Probably more.
<adam12>
Pika: Jim was a great public speaker. You should watch some of his talks (and maybe the one where he sings Has Anybody Seen My Code?)
<Pika>
I will look into it! Thank you very much for letting me know :D
davidw has quit [Ping timeout: 268 seconds]
impermanence has quit [Ping timeout: 260 seconds]
lineus has quit [Ping timeout: 240 seconds]
FernandoBasso has quit [Remote host closed the connection]
rainmanj_ has quit []
rainmanjam has joined #ruby
<adam12>
gitter1234: Looks like you can't use `attach` in a callback. In the callback, try something like `self.avatar = StringIO.new(Identicon.blob_for(email))`
<adam12>
Pika: Do you have an example of what you're working on? Something I could reproduce locally?
<Pika>
I just switched to the nokogiri xml builder which seems to let me do what I wanted :{
<adam12>
Pika: Great!
<Pika>
:D
lineus has joined #ruby
jcalla has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
markopasha has quit [Quit: Leaving]
fphilipe_ has joined #ruby
wildtrees has quit [Quit: Leaving]
Pika has quit [Ping timeout: 260 seconds]
Swyper has quit [Remote host closed the connection]
ttoocs has joined #ruby
anveo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tpanarch1st_ has joined #ruby
tpanarch1st has quit [Ping timeout: 255 seconds]
pandakekok9 has joined #ruby
zdm has quit [Remote host closed the connection]
fphilipe_ has quit [Ping timeout: 272 seconds]
Bounga has joined #ruby
akem__ has joined #ruby
akemhp_ has quit [Ping timeout: 260 seconds]
Bounga has quit [Ping timeout: 272 seconds]
akemhp_ has joined #ruby
pandakekok9 has quit [Ping timeout: 240 seconds]
akem__ has quit [Ping timeout: 272 seconds]
pandakekok9 has joined #ruby
AJA4350 has joined #ruby
Swyper has joined #ruby
zdm has joined #ruby
Swyper has quit [Remote host closed the connection]
shirak_ has quit [Ping timeout: 265 seconds]
mossplix has quit [Remote host closed the connection]
Swyper has joined #ruby
akem__ has joined #ruby
akemhp has joined #ruby
akemhp_ has quit [Ping timeout: 258 seconds]
davidw has joined #ruby
davidw has quit [Changing host]
davidw has joined #ruby
akem__ has quit [Ping timeout: 272 seconds]
troulouliou_dev has quit [Quit: Leaving]
bruce_lee has quit [Ping timeout: 272 seconds]
bruce_lee has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
zdm has quit [Quit: zdm]
davidw has quit [Ping timeout: 272 seconds]
zdm has joined #ruby
troulouliou_dev has joined #ruby
zdm has quit [Client Quit]
zdm has joined #ruby
fphilipe_ has joined #ruby
jerme_ has quit [Ping timeout: 265 seconds]
matti has quit [Ping timeout: 265 seconds]
wbnns has quit [Read error: Connection reset by peer]
ryzokuken has quit [Read error: Connection reset by peer]
wbnns has joined #ruby
ryzokuken has joined #ruby
matti has joined #ruby
s3nd1v0g1us has quit [Quit: WeeChat 2.6]
jerme_ has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
ctp has quit [Ping timeout: 258 seconds]
mossplix has joined #ruby
ctp has joined #ruby
d0liver has quit [Ping timeout: 260 seconds]
d0liver has joined #ruby
duderonomy has joined #ruby
grilix has quit [Ping timeout: 245 seconds]
AJA4350 has quit [Quit: AJA4350]
grilix has joined #ruby
jenrzzz has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
jaequery has quit [Remote host closed the connection]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
mossplix has quit [Remote host closed the connection]
bambanx has joined #ruby
troulouliou_dev has quit [Remote host closed the connection]
s2013 has joined #ruby
<s2013>
>> a = [1,2,3]; a.last;
<s2013>
>> a = [1,2,3]; p a.last;
<havenwood>
#=> 3
<s2013>
#=> 3
<s2013>
how do you do the ruby thin on irc?
<s2013>
like run the code
pandakekok9 has quit [Remote host closed the connection]
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SCHAPiE has joined #ruby
tsujp has joined #ruby
guardian has quit [Ping timeout: 258 seconds]
guardian has joined #ruby
weeirc8087 has quit [Ping timeout: 265 seconds]
gix has joined #ruby
tfreedman has joined #ruby
guardian has quit [Ping timeout: 258 seconds]
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pandakekok9 has quit [Ping timeout: 240 seconds]
guardian has joined #ruby
Fernando-Basso has quit [Quit: Leaving]
pandakekok9 has joined #ruby
guardian has quit [Ping timeout: 260 seconds]
<gitter1234>
Trying to make it so that users must be approved by admin before they can post. Also trying to get it as RESTful as possible too: https://gist.github.com/1234dev/0f37e7935bf2efe85070bd1a7786d1a4 - any thoughts? Getting `No route matches {:action=>"update", :controller=>"approvals"}, missing required keys: [:id]`
guardian has joined #ruby
tsujp has joined #ruby
troulouliou_dev has joined #ruby
guardian has quit [Ping timeout: 260 seconds]
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
guardian has joined #ruby
alexherbo22 has joined #ruby
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo22 is now known as alexherbo2
alex`` has quit [Ping timeout: 265 seconds]
alex`` has joined #ruby
lucasb has joined #ruby
TCZ has joined #ruby
fphilipe_ has quit [Ping timeout: 260 seconds]
<lmat>
havenwood: Thanks!
<lmat>
havenwood: Are you suggesting adding that helper into "production" code? And it has a special path for integration tests to get the test logged in?
<lmat>
havenwood: The login function looks like this: session[:user_id] = user.id
<lmat>
havenwood: Oh yeah, that's what you have. But what is "controller" in what you posted? (!!controller.current_user if controller.respond_to? :current_user)
Swyper has joined #ruby
<lmat>
undefined method `integration_test?'
tsujp has joined #ruby
cd has joined #ruby
<lmat>
Is this just common parlance!? def integration_test?; defined?(post_via_redirect); end;
fphilipe_ has joined #ruby
pandakekok9 has quit [Quit: Overthrow the fascist regime of Rodrigo Duterte! VIVA CPP-NPA-NDF!]
bvdw has quit [Read error: Connection reset by peer]
fphilipe_ has joined #ruby
bvdw has joined #ruby
<fratis>
Couple things. First, it looks like your call should be to ServiceLayer.login, not ServiceLayer.new.login, since login is a class method, not an instance method.
<fratis>
Second, your login method doesn't have any arguments defined, so when you pass @credentials to it, the method isn't actually able to do anything with them.
<ZAJDAN>
thank YOu...a first I will fix the with the new
<lmat>
I have a rails controller with a "new" action. The body of that new action is one line: @transaction = TransactionLog.new;
<lmat>
When I call that action from a unit test, I see the following in the logs:
<lmat>
Started GET "/transactions/new" Processing by TransactionsController#new as HTML
<lmat>
Rendering users/new.html.erb within layouts/login
<lmat>
Why would /transactions/new/ render users/new.html.erb ?
<ZAJDAN>
fratis: how can I pass the params or variable from the controller to the class method?
<fratis>
instead of def self.login, do def self.login credentials
<fratis>
then in the method, you can use `credentials` as a local variable containing whatever you passed to it
<ZAJDAN>
fratis: and in the controller it should be as shared variable? @credentials
<fratis>
@lmat I'm pretty sure that's just a rails convention
<fratis>
@ZAJDAN Hard to know without more context, but that seems reasonable.
DaRock has quit [Ping timeout: 265 seconds]
<lmat>
fratis: There is a convention that /transactions/new goes to users/new.html.erb? That's a bad convention ;-)
<fratis>
Oh I missed that! :P
kristian_on_linu has quit [Remote host closed the connection]
guardian has quit [Ping timeout: 272 seconds]
<fratis>
Looks like you might have some kind of authentication mechanism that's rendering the login screen bc the user doesn't have access to transactions/new?
<fratis>
Wild guess.
<lmat>
fratis: Excellent guess, I'll take a look.
<lmat>
I have a log in helper function that appears to be succeeding...maybe I should assert that it succeeds.
gray_-_wolf has quit [Quit: WeeChat 2.7]
<lmat>
Yeah, after post login_path params: {session:.....} I added assert_redirected_to "/"; This succeeds for my already-succeeding test (post transactions_path), but does not succeed for the new test: get new_transaction_path
<lmat>
How do I verify that the "new" action is actually being called?
guardian has joined #ruby
<fratis>
Add a puts in there and check your logs?
<lmat>
fratis: What should I try to log? new_transaction_path ?
<lmat>
That gives /transactions/new
<fratis>
I mean in your `def new` method, put a line at the beginning that says something like `puts "THE NEW ACTION IS NOW RUNNING Y'ALL WOO HOO"`
<fratis>
then watch your terminal to see if that shows up
<lmat>
yeah, okay.
<lmat>
I don't know if that works in unit tests... seems like anything I put there is eaten away...I don't know if I've tried puts though
<havenwood>
lmat: that's ^ one way to do it. i dunno if Rails 6 has any helpers along these lines.
<havenwood>
I haven't had a Rails app since 5.2.
weeirc8087 has joined #ruby
<lmat>
havenwood: defined?(post_via_redirect) is false even in my integration tests. I noticed that it's deprecated, and I figured it has been removed in my version?
<havenwood>
lmat: yup, i'm dated it seems
<havenwood>
lmat: looking at an old codebase of mine that's no longer maintained
<havenwood>
lmat: maybe there's a helper now? if not, you could pick another thing only available in integration tests. it's not a pretty solution.
<havenwood>
lmat: From just the code you've shown, I don't see the issue.
<lmat>
havenwood: :'( I'll keep digging
jokester has quit [Client Quit]
<havenwood>
lmat: You might try the #rails channel or the Rails Slack. Can you just share the repo you're working on? Someone might be able to help you track it down with the code.
<havenwood>
lmat: Just an assertion of a new_ and a ROLLBACK isn't anything to go on. (At least not that my pre-coffee brain can spot.)
<lmat>
havenwood: Can't share the code.
<lmat>
havenwood: I just learned ruby yesterday. I was hoping there would be something obvious ^_^
jokester has joined #ruby
<havenwood>
lmat: Not in what you've shown. PS - It's better to share text rather than images, for a variety of reasons.
<lmat>
havenwood: okay
jokester has quit [Client Quit]
<havenwood>
lmat: If you could share the relevant part of your schema and model, someone can probably spot the issue.
<havenwood>
lmat: Often, with Rails, folk will share a Gist with multiple files listed. Rails breaks things apart into different folders so you have to gather the relevant parts together for someone to get the picture.
<havenwood>
lmat: For your case, I'd think the relevant parts would be the routes, controller, model, maybe schema, test, and fixtures?
<lmat>
havenwood: Yeah, that makes sense.
howaboutyes has joined #ruby
Ven`` has joined #ruby
<lmat>
havenwood: You know...there probably shouldn't be a handler for new transactions. They should only be created by the backend...
<lmat>
I'll just delete the new action, and add only: [:create] in the routes.
reber has joined #ruby
bsdband10 has joined #ruby
factormystic has quit [Ping timeout: 260 seconds]
bsdbandit-01 has quit [Ping timeout: 265 seconds]
sergioro has joined #ruby
bsdband10 has quit [Ping timeout: 252 seconds]
impermanence has quit [Ping timeout: 272 seconds]
howaboutyes has quit [Quit: Leaving]
<adam12>
gitter1234: Why'd you change from a link to a form for approving?
factormystic has joined #ruby
Emmanuel_Chanel has quit [Quit: Leaving]
<gitter1234>
Oh hey there adam12! It was suggested to me by this guy in the slack channel. He insisted it was the right thing to do since I've disabled JS. I'll probably change it to a button_to later on and use CSS to disguise it as a link.
<adam12>
gitter1234: You won't be able to use the update route that Rails creates for you if you're doing it like that. It expects an id in the URL (so you pass it to the route helper). If you want to continue using checkboxes like you are, you'll need a different style route that doesn't accept any params. If you want to go back to how it was, use link_to or button_to, and just force the method as `put`.
<adam12>
gitter1234: Oh! You disabled JS.
reber_ has joined #ruby
<gitter1234>
Yep. Part of the reason he wanted me to change was to make it more RESTful as well. I'm not yet sure how I feel about it though
<adam12>
gitter1234: You could still use button_to I think. IIRC, it generates a form for you.
<gitter1234>
I most likely will use button_to. Checkbox for this kinda stuff feels a bit odd :)
<adam12>
My knowledge of Rails is ancient so it's challenging to remember.
reber has quit [Ping timeout: 268 seconds]
<gitter1234>
:D
<adam12>
Also, when using gist, can you break up your files into multiple files inside the gist? There's an Add File button. As havenwood mentioned above to someone else, it adds syntax highlighting which can be helpful when looking at strange code quickly.
<gitter1234>
oh yeah! i was considering that
<gitter1234>
i think it should be possible to do ```rb to enable syntax highlighting as well though
<adam12>
gitter1234: That might work fine too. Either or, but syntax highlighting makes it a bit more enjoyable.
<gitter1234>
a bit selfish of me perhaps. ill start enabling it from now on :)
Emmanuel_Chanel has joined #ruby
<havenwood>
gitter1234: more folk help with syntax highlighting. i know i sometimes ignore questions without the pretty colors as a lure.
<gitter1234>
i didnt know that was a thing
_phaul has joined #ruby
<adam12>
Easy to look at issues definitely get more eyeball from me as well. And a reproducable example I'll usually try immediately.
<gitter1234>
tbh im part color blind so it didnt really matter to me lol
Swyper has quit [Remote host closed the connection]
<gitter1234>
nice
<gitter1234>
reproducable example what do you mean?
<adam12>
gitter1234: Hard with Rails because changes sprawl multiple files (so it would have to be a git repo) but the entire problem in something I can download and run.
<gitter1234>
i remember runnable.com which used to let you run live rails apps, was pretty cool while it lasted
phaul has quit [Ping timeout: 260 seconds]
Swyper has joined #ruby
<gitter1234>
ill start doing that from now on too. i always wanted to ask you and the others - do you want the full app?
<havenwood>
Pry and pry-doc now work on master branches, if anyone is annoyed at 2.7 warnings. Grab latest commit with:
<adam12>
gitter1234: If you're working on an app that can be shared, it's easier to do it like that. Especially if you're using stock database connections like sqlite and files.
<adam12>
havenwood: Ah nice. I saw that error a few days ago and was wondering if I should dig into it.
<adam12>
havenwood: I did 2 weeks of Ruby tips for my current consulting gig and the last tip was Ruby documentation tooling / access.
<havenwood>
adam12: Just need releases cut now.
<adam12>
havenwood: And inevitably `? somemethod` was spewing warnings.
<havenwood>
Hahah
<havenwood>
Yeah
<adam12>
gitter1234: If you share the full app we might be able to fix your avatar bits.
<gitter1234>
working on it :D
bsdbandit-01 has joined #ruby
<lmat>
Rails: I'm testing a controller action (index). Index is called using get transaction_path; after returning from my index function, the application hangs before returning control back to my test.
<lmat>
It's hanging in middleware somewhere. The processor is pegging the whole time.
<lmat>
Using pry and stepping, it looks like a deadlock? (but the processor is being used, so live lock?)
subfj has joined #ruby
impermanence has joined #ruby
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
ur5us has quit [Read error: Connection reset by peer]
jintseng has quit [Ping timeout: 248 seconds]
mossplix has quit [Remote host closed the connection]
ZAJDAN1 has joined #ruby
Ai9zO5AP has joined #ruby
ZAJDAN has quit [Ping timeout: 272 seconds]
<adam12>
Installing sassc 2.2.1 with native extensions zzzzzzzzz
<adam12>
Forgot how slow compiling sassc was. Haven't touched sass since I started using Tailwind.
<gitter1234>
cool
<gitter1234>
ive actually completed the layout based on www.bulma.io which i'll merge once these other issues have been fixed.. not the biggest fan of css frameworks since they really mess up the semantics of the html but.. quick and easy if one has better things to do i guess
<adam12>
gitter1234: You'd probably hate Tailwind then :)
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gitter1234>
:D
<adam12>
Tailwind, Unpoly, and AlpineJS have really changed the way I build apps.
subfj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ZAJDAN1>
hi ..In controller I have: @credentials = params[:session].to_json ...how could I pass this variable into my class method which I have in /lib