<havenwood>
felipec: Yeah, yield and block work fine together. I was just curious what was being yielded, since the value isn't being used.
<havenwood>
felipec: I assume used for side effects?
poontangmessiah has quit [Ping timeout: 240 seconds]
wildtrees has quit [Quit: Leaving]
<havenwood>
felipec: My `block.call` comment was solely about mixing `block` and `yield` usage. maybe just for old school performance reasons, but I prefer `yield` to `block.call`. If I sacrifice the performance to use `&block` then I `block.call` instead of `yield`. Not important, particularly.
<havenwood>
I just all-yield as preference, but if I block, I all-block fully.
poontangmessiah has joined #ruby
<havenwood>
Now that passing &block through is cheaper, there may be an argument for using yield with &block, in a particular circumstance. ¯\_(ツ)_/¯
<gitter1234>
1) Should I put anything in routes.rb? 2) Should I toggle from the model instead? 3) I seem to be repeating myself a lot - could any of this be clean up? 4) The whole privilege-changing attributes being changed via mass-assignment - how do I prevent that?
dalpo has joined #ruby
ropeney_ has joined #ruby
bodqhrohro has quit [Ping timeout: 268 seconds]
bodqhrohro has joined #ruby
pizzaiolo has joined #ruby
ropeney has quit [Ping timeout: 268 seconds]
cadeskywalker has joined #ruby
akemrir has joined #ruby
umjisus_ is now known as umjisus
chalkmonster has quit [Quit: WeeChat 2.7]
<gitter1234>
howdy akemrir! you left quite abruptly last night lol
houhoulis has quit [Remote host closed the connection]
thecoffemaker has quit [Ping timeout: 268 seconds]
ropeney has joined #ruby
swistak35 has quit [Ping timeout: 240 seconds]
swistak35 has joined #ruby
thecoffemaker has joined #ruby
xNetX0 is now known as NODE
thecoffemaker has quit [Changing host]
thecoffemaker has joined #ruby
ropeney_ has quit [Ping timeout: 240 seconds]
gylpm has quit [Ping timeout: 240 seconds]
gylpm has joined #ruby
CustosLimen has joined #ruby
<CustosLimen>
hi
<CustosLimen>
where is the documentation for initialize/new
<akemrir>
gitter1234: I know where you are creating error ;)
SqREL has joined #ruby
<akemrir>
gitter1234: you are using has_one_attached and then later overwrite method avatar, new avatar method is returning string. New method shadows previous functionality.
<akemrir>
gitter1234: it looks, you need to generate this identicon while/after avatar upload, then attach it, to be able to process it later
<adam12>
gitter1234: Rename `avatar` method to something like `generate_avatar`
<adam12>
gitter1234: Actually, get rid of the avatar method completely.
<adam12>
gitter1234: When you refresh /posts, you should have a different error now?
thecoffemaker has quit [Read error: Connection reset by peer]
<gitter1234>
adam12: yes indeedie-o! `variant delegated to attachment, but attachment is nil`
<adam12>
gitter1234: Load up a Rails console, and try something like this: User.all.each { |user| user.save }
TCZ has joined #ruby
<gitter1234>
adam12: NameError (undefined local variable or method `user' for #<User:0x00000fe044c063e8>)
<adam12>
gitter1234: The backtrace should point to the callback you made?
<adam12>
gitter1234: send_to_active_storage
weeirc8087 has quit [Ping timeout: 240 seconds]
<gitter1234>
yes!
<gitter1234>
yes it does
<adam12>
gitter1234: Drop the user at the beginning. avatar.attach..therest
<adam12>
gitter1234: Re-run the rails console command.
<gitter1234>
its doing something.. my computer is extremely slow so its hard to tell (its been dropped on its head more times than a baby.. it was even involved in a street fight once.. has all kinds of dents on it). no errors so far tho
<gitter1234>
User Load (2.1ms) SELECT "users".* FROM "users" and nothing more happens. i tried reloading in the browser but get the same error as previously
woodruffw has quit [Ping timeout: 240 seconds]
duderonomy has joined #ruby
<adam12>
gitter1234: OK. I'd just try doing it manually without the callback and see if it works. Then go from there.
woodruffw has joined #ruby
woodruffw has quit [Changing host]
woodruffw has joined #ruby
weeirc8087 has joined #ruby
<adam12>
gitter1234: user = User.first; user.avatar.attach(Identicon.blob_for(user.email))
<adam12>
gitter1234: then check user.avatar.class
grilix has quit [Ping timeout: 252 seconds]
<gitter1234>
adam12: not getting any response, laptop fan is spinning out of control. looks like some infinite loop thing idk
<gitter1234>
ill get back to you once i figure out whats wrong!
turbo_choo has joined #ruby
fphilipe_ has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Inline has joined #ruby
<gitter1234>
adam12: it just freezes at user.avatar.attach(Identicon.blob_for(user.email))
<adam12>
gitter1234: OK. I'd probably start by looking at the attach method provided by ActiveSupport; what types of objects does it accept/expect? Maybe it doesn't like the Identicon blob.
<adam12>
gitter1234: Try passing it a real file of something local. That way you can identify if the attach is working fine.
<gitter1234>
great idea
<adam12>
gitter1234: When I suggested that originally, I thought that blob might have been an issue because it's a string. You can wrap it in a StringIO object to make it look like an IO object and that _might_ make ActionStorage happy.
conta1 has joined #ruby
<adam12>
And when I said ActiveSupport earlier, I meant ActiveStorage. or ActionStorage... I don't get Rails naming :)
<adam12>
lmat: Hah! Well in Rails 6, the autoloader is new with a new mechanism. It doesn't save you from hell directly, but it makes the process much nicer. I use Zeitwerk in some non-rails projects to much success.
<adam12>
lmat: It's a sacrifice to be made for reloading, sadly. To perform an inprocess reload, the constant has to be undefined and the file it was loaded from removed from the array of files already required. This requires some constraints to keep things sane. But it does and can work around it by other means.
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
weeirc8087 has quit [Ping timeout: 265 seconds]
<lmat>
adam12: Is there a built-in way to mock for unit tests?
<adam12>
lmat: Rails ships with Minitest (so does Ruby, tbh). Minitest has Minitest::Mock.
<lmat>
Okay, I'll start looking at minitest first.
phaul has quit [Ping timeout: 265 seconds]
woodruffw has quit [Ping timeout: 268 seconds]
<adam12>
lmat: If this is an existing project it might be running rspec, which is another test framework.
<lmat>
adam12: good idea. There isn't much code here yet, but I'll look at that.
<gitter1234>
adam12: this looks ok right? still freezes... file = File.open(public/apple-touch-icon.png); user = User.first; user.avatar.attach(file)
phaul has joined #ruby
<gitter1234>
"public/apple-touch-icon.png" in quotes rather
<adam12>
gitter1234: Presuming you're quoting.
<lmat>
adam12: What am I looking for? grep rspec *; and grep rspec test -ri; showed nothing
<gitter1234>
yep
<gitter1234>
:)
<adam12>
gitter1234: Yeah. That looks perfect to me. Maybe look at your ActiveStorage settings? Is it trying to upload to S3 or something?
<gitter1234>
will do, thanks!
<adam12>
lmat: Normally it would be in your Gemfile. `rspec-rails`. If not, then you are using the Rails default which is minitest.
<lmat>
adam12: sweet. I just looked through the tests. I'm pretty sure there's no mocking. Just calling "real" methods then asserting.
fangs2 has joined #ruby
<fangs2>
hello
<fangs2>
i'm a new user
<fangs2>
gem always installs to a wrong architecture, any hints?
<lmat>
adam12: ActionDispatch::IntegrationTest is that a tell?
<lmat>
fangs2: What is it doing and what do you expect it to do?
<adam12>
lmat: Rails makes their own test classes for certain things, which include certain things (like the `get` method).
<fangs2>
and I get compile errors, it wants to compile to x64 but im on arm64
<fangs2>
if i correct the makefile, gem install seems to replace the makefile with the bad one
<adam12>
gitter1234: Interesting.
<adam12>
fangs2: The Makefile is autogenerated I'm guessing. You'd have to maybe adjust extconf.rb.
Omnilord has quit [Quit: Leaving]
<adam12>
fangs2: What's the adjustment you're making anyways? Can you share it in a gist or paste?
<lmat>
adam12: Ah, okay. I was liking using that. So if I move to minitest, I'll extend Minitest::Test and won't get "get" anymore?
<fangs2>
good, thanks, is there an extconf.rb per gem?
<fangs2>
I make no adjustment, only wanted to install
<adam12>
lmat: Right. You'd have to bring in Rack::Test which is what `get` is from. `class Foo < Minitest::Test; include Rack::Test::Methods; end`
<lmat>
adam12: Thanks!
* lmat
looks up include vs require ^_^
<adam12>
fangs2: There normally is. It's often in `ext/`. It will generate the Makefile. If it's not building on arm64 and can be fixed in the extconf.rb then it might be a good PR.
<fangs2>
sorry but what do you mean with PR
<adam12>
fangs2: Pull Request.
<fangs2>
ah, I see
<fangs2>
thanks I will try
<fangs2>
the error came after bundle install
<fangs2>
this bundle seems to be a mix of some packages
<fangs2>
some things you never find by a simple googling
<lmat>
adam12: did the include, but now the route helpers don't work :-)
<adam12>
lmat: There's a bunch of other stuff that has to happen; you'd have to define the `app` method to point to your Rails/Rack app. Definitely use the Rails conveniences if you're in Rails.
<fangs2>
probably adam, I cant open the link right now, but I feel it will correct the problem
<adam12>
fangs2: OK good luck!
<fangs2>
thanks have a nice day
fangs2 has quit [Remote host closed the connection]
jenrzzz has joined #ruby
<lmat>
adam12: Oh, I get the "test" keyword back when I extend ActiveSupport::TestCase. I'm not sure what that is, but ActiveSupport sounds so supportive of my efforts.
akemrir has quit [Quit: WeeChat 2.7]
<adam12>
lmat: It's a DSL around defining methods. `def test(test_name, &block); define_method("test_#{test_name}", block); end`. Something like that but more complex (sanitizing test name into a valid method name, etc).
davor_ has joined #ruby
<lmat>
adam12: sweet
<lmat>
Oh, there's also ActionController::TestCase so many choices!
<adam12>
fangs2: gem fetch sha3; gem unpack sha3-1.0.1.gem; cd sha3-1.0.1; vim ext/sha3/extconf.rb; rake build; gem install pkg/sha3-1.0.1.gem
<fangs2>
I will try adam, thanks again
fangs2 has quit [Remote host closed the connection]
<adam12>
gitter1234: I wouldn't. You should always have an avatar, since you're building them from an email address which you should also always have. No?
conta1 has quit [Quit: conta1]
fphilipe_ has joined #ruby
<adam12>
gitter1234: Nothing wrong with the null object pattern but it's not going to solve your problem here.
<gitter1234>
yep, should always be there..
<gitter1234>
good to know :)
<adam12>
gitter1234: Maybe this is a problem with spring. Try shutting down your entire Rails app (making sure to shut it down via spring) then start it again.
<adam12>
gitter1234: Sometimes Spring/Rails holds on to things longer than it should.
<gitter1234>
hehe.. i just disabled that actually because i had some bad experience with it in the past. also i noticed that it spawned several different processes when running rails console so
<adam12>
gitter1234: Then from there, try just attaching that normal file you were doing earlier. If it's still in deadlock.. I'm not sure.
<adam12>
gitter1234: Ah OK. Did that StackOverflow post not yield anything fruitful? I only glanced over it.
ellcs has quit [Ping timeout: 240 seconds]
<gitter1234>
nah just a buncha comments that led nowhere
<lmat>
adam12: sweet!
<lmat>
adam12: (regarding .stub)
<adam12>
lmat: If you look at the ancestors of those test classes, I bet they're related. ActiveSupport::TestCase is probably an ancestor of ActionDispatch::IntegrationTest. You can see it in the Rails console likely. ActionDispatch::IntegrationTest.ancestors
ellcs has joined #ruby
duderonomy has joined #ruby
fangs2 has joined #ruby
<fangs2>
sorry , more errors
<fangs2>
Invalid gemspec in sha3.gemspec: no such file or directory
<fangs2>
after "rake build"
<lmat>
adam12: Also in "SubscriptionService.stub :new, mock do" what does ":new" mean? I think I understand colon-variables, but is ":new" a predefined minitest constant, or does it mean "mack the "new" function? Or does it mean "make a new mock"?
<lmat>
heh s/mack/mock
<lmat>
smack the mack to a mock
<adam12>
fangs2: I'm not sure how much more I'll be able to help you blindly. If you can share the output in a gist or dpaste then maybe we can look. But I built it fine here since I was curious (I'm on x86_64 tho)
<adam12>
lmat: It mocks the `new` method on SubscriptionService.
<fangs2>
sorry, I cant paste or dont know how, im on a cli app
<adam12>
lmat: The colon-variable is called a symbol, fyi.
<lmat>
adam12: Ah, symbol, thanks. So if I wanted to mock the "initialize" function (constructor) of an object, I might MyClass.stub :initialize, mock do.. ?
<adam12>
lmat: Initialize is a special case. You'd want to mock `new`.
<adam12>
lmat: It's the only special case (AFAIK).
<lmat>
adam12: thanks!
<lmat>
adam12: Just to keep straight, obj = MyObject.new; calls MyObject's "def initialize", right?
ellcs has quit [Remote host closed the connection]
<lmat>
then obj.new calls MyObject's "def new"
<adam12>
lmat: Yes for the first; but tbh, I've never seen `new` defined on a class before, so I presume it would work as it's not defined on the eigenclass, but it's unexpected in Ruby because it's somewhat abiguous.
<lmat>
adam12: I think it's not ambiguous because "new" is an (non-static) member function, but "initialize" is a static member function.
<adam12>
lmat: Well I guess it depends on your team. If I'm working with juniors, I'd prefer less ambiguity and wouldn't permit `new` as an instance method. But there's nothing stopping you AFAIK with Ruby being concerned.
<lmat>
adam12: I see, thank you.
<adam12>
gitter1234: Are you attaching files elsehwerE? Just the avatar causing you grief?
anveo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gitter1234>
just avatar.. i have regular photo uploads and its working fine..
<gitter1234>
my post model has: has_many_attached :images
<fangs2>
OK, I managed to build it, after correcting gemspec, what was the final step after that?
<adam12>
gitter1234: what happens when you tell it to not identify the attachment? user.avatar.attach(file, identify: false)
<adam12>
fangs2: gem install pkg/sha3-1.0.1.gem
<adam12>
gitter1234: Do you make your own attachments table in a migration? or is that handled for you?
<lmat>
My class uses params.require(:transaction)... How can I prepare for this in a unit test?
<gitter1234>
adam12: it was made with active_storage:install yeah
<fangs2>
success adam, thank you
<adam12>
fangs2: cheers!
<gitter1234>
adam12: well look at that.. no freeze!
<adam12>
gitter1234: I wonder if it uses imagemagick or graphicsmagick to identify files...
<gitter1234>
ArgumentError (wrong number of arguments (given 2, expected 1)) though
<gitter1234>
ok no freeze this time, just: ArgumentError (missing keyword: filename)
<adam12>
gitter1234: Are you using the new or old attach mechanism? I'd switch back to the old version (user.avatar.attach(file))
TCZ has joined #ruby
<gitter1234>
ooooh... check this out!
<gitter1234>
or, well, ArgumentError (Could not find or build blob: expected attachable, got #<File:public/apple-touch-icon.png>)
<gitter1234>
using file = File.open("public/apple-touch-icon.png"); user = User.first; user.avatar.attach(file)
weeirc8087 has quit [Ping timeout: 268 seconds]
<adam12>
gitter1234: See if you can take it from here; and then circle back to fix the callback.
unixabg has left #ruby [#ruby]
<gitter1234>
ill do my best!
d^sh has quit [Ping timeout: 265 seconds]
GodFather has joined #ruby
<lmat>
I think the answer to the params problem is: don't unit test controllers. Controllers should be tested with integration tests.
meinside has quit [Quit: Connection closed for inactivity]
<adam12>
lmat: If you haven't given the Rails guide a read I encourage you to do so. Especially around testing, since everyone seems to have a slightly opinion of what constitutes a test of what sort, and Rails doesn't differ in that it has it's own opinion.
fangs2 has quit [Remote host closed the connection]
<lmat>
adam12: okay, thank you!
ttoocs has quit [Ping timeout: 268 seconds]
TomyWork has quit [Remote host closed the connection]
<lmat>
adam12: By the way, the new function is created by rails generate.
<lmat>
I don't mean to contradict you; it may be a bad idea. All I'm saying is that it's default and common.
<lmat>
(bad idea for junior devs: it's ambiguous with the "new" constructor call)
<lmat>
"do" always introduces a lambda function? (And lambda function parameters between pipes, got it!)
TCZ has quit [Quit: Bye Bye]
turbo_choo has quit [Ping timeout: 265 seconds]
weeirc8087 has joined #ruby
abe has joined #ruby
mossplix has quit [Remote host closed the connection]
davidw has joined #ruby
davidw has quit [Changing host]
davidw has joined #ruby
phaul has quit [Ping timeout: 272 seconds]
mossplix has joined #ruby
wildtrees has joined #ruby
Swyper has quit [Remote host closed the connection]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
davidw has quit [Ping timeout: 272 seconds]
alexherbo24 has joined #ruby
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo24 is now known as alexherbo2
fphilipe_ has quit [Ping timeout: 268 seconds]
alex`` has quit [Ping timeout: 268 seconds]
howdoi has joined #ruby
alex`` has joined #ruby
<lmat>
/win 1
chalkmonster has joined #ruby
poontangmessiah has quit [Ping timeout: 265 seconds]
Swyper has joined #ruby
woodruffw has joined #ruby
woodruffw has quit [Changing host]
woodruffw has joined #ruby
phaul has joined #ruby
Pika has joined #ruby
<Pika>
I'm trying to use XML builder.... I put a stacktrace into one of my like builder.tags(stackTrace), but I want to escape all the <> and other such non XML safe characters. How would I do this?
<gitter1234>
speaking of slimpixels, strange coincidence watching queen & slim right now just downloaded the torrent, it's one of those rare ones that you can tell is gonna be good after just a few seconds in
<Pika>
https://github.com/jimweirich/builder I tried reading the documentation here.... but! the escape and unescape section doesn't seem to make sense to me since it looks like it's just putting as an attribute and not into the body
<Pika>
it also says something like the body should be automatically escaped, but it seems to not be the case?
tdy has quit [Remote host closed the connection]
vondruch has joined #ruby
phaul has quit [Ping timeout: 260 seconds]
davidw has joined #ruby
davidw has joined #ruby
davidw has quit [Changing host]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
alexherbo23 has joined #ruby
alex`` has quit [Ping timeout: 265 seconds]
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo23 is now known as alexherbo2
jaequery has joined #ruby
jenrzzz has joined #ruby
alex`` has joined #ruby
<Pika>
Alternatively how what's the most performant way right now to encode some html stuff from like <> to the &whatever; characters
<Pika>
My main concern is like... I'm dumping the StackTrace into <xml>StackTrace</xml> so I don't want any of the >whatever <stuff characters to be interpreted as further XML
sgen has joined #ruby
<adam12>
lmat: Ohh! I forgot Rails uses the `new` method as an action. Yes! OK, that's one place I've seen it.
<Pika>
The nekogiri builder doesn't look much different from the other 'builder' imo... what makes it better? =X
<al2o3-cr>
not better, just my preference ;)
<adam12>
Pika: Nokogiri is _possibly_ faster since it uses libxml2. Obviously you'd want to do your own benchmarks.
<adam12>
Pika: Maybe you could use `CGI.escapeHTML(stackTrace)`
<lmat>
gem uninstall --all; doesn't work. it says: "ERROR: While executing gem ... (NameError)\nuninitialized constant Gem::RDoc"
<lmat>
I may have borked my gem installation by installing things concurrently :-/
<lmat>
I'm thinking I should remove everything and start over. Alternatively, maybe there's some way to reinstall without removing? I don't care.
<adam12>
lmat: The're installed in a folder. You could try just rm'ing the folder.
<adam12>
lmat: `gem env` and look for GEM PATHS
<al2o3-cr>
lmat: "gem i rdoc" first
phaul has joined #ruby
<Pika>
I'll try that, thank you!
mossplix has quit [Read error: Connection reset by peer]
<lmat>
adam12: I was worried that some accounting would be off that way...
mossplix has joined #ruby
<adam12>
lmat: Maybe; but if you're going nuclear enough to remove everything and start over, might as well try one step just below it.
<adam12>
lmat: Could try re-installing rdoc as well, like al2o3-cr mentioned.
<lmat>
Yeah, I installed rdoc, and got much further. Now I get "You don't have write permissions for the /usr/lib/ruby/gems/2.7.0 directory."
phaul has quit [Ping timeout: 272 seconds]
turbo_choo has joined #ruby
Swyper has quit [Remote host closed the connection]
mossplix has quit [Remote host closed the connection]
<al2o3-cr>
lmat: you on arch linux?
<lmat>
al2o3-cr: fo sho
<lmat>
I think running sudo gem uninstall -all; would be a bad idea from what I've read online.
<al2o3-cr>
lmat: did you add: PATH="$PATH:$(ruby -e 'puts Gem.user_dir')/bin"
<lmat>
(though I would then have permission to write to /usr/lib/ruby/gems/2.7.0 and everywhere else...)
<lmat>
al2o3-cr: I hard-coded the path, but it should come out to the same thing, let me see.
<lmat>
yeah, that's on my path.
<lmat>
al2o3-cr: It went through a lot of packages before giving that error.
<al2o3-cr>
lmat: pastebin 'gem env'
<lmat>
A bunch of "... depends on ...If you remove this gem..."
<lmat>
I've only installed one gem: rails. Maybe I'll just try to uninstall that. Maybe addressable comes pre-installed or something.
<lmat>
Successfully uninstalled rails-6.0.2.1
<lmat>
Now I want to get the packages that were installed to support rails...
chalkmonster has quit [Ping timeout: 268 seconds]
TCZ has joined #ruby
<AndroidKK>
if i've got an array that contains pairs of numbers, what would be the best way to delete an entire pair if one of the numbers in the pair is above a certain value? sorry for any messy code: https://waifupaste.moe/raw/tE.txt
<lmat>
al2o3-cr: Well, I'll just keep working and see if everything works now properly ^_
<al2o3-cr>
lmat: it should do now.
<lmat>
al2o3-cr: cool
<al2o3-cr>
make sure to restart your terminal
<al2o3-cr>
to take effect.
<al2o3-cr>
lmat: actually, yes restart, then pastebin 'gem env' again.
oncall-pokemon has joined #ruby
<adam12>
AndroidKK: First; almost everywhere you're using sort! and uniq! you probably want their non-bang version (sort and uniq).
<adam12>
AndroidKK: What's the certain value? where does it come from?
AJA4351 has joined #ruby
<lmat>
al2o3-cr: it's going good!
<adam12>
AndroidKK: The easiest solution is: pair.any? {|n| n > THRESHOLD }
<lmat>
I'm following a tutorial. It generated an integration test and the setup action is: "@post = posts(:one)"
<lmat>
Where is "posts" defined?
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4351 is now known as AJA4350
Swyper has joined #ruby
<lmat>
The class is PostsController < ApplicationController so I don't think it's in the superclass.
<lmat>
The reason I ask about "posts" is because I want to know how it interprets ":one".
jenrzzz has quit [Ping timeout: 265 seconds]
<lmat>
I ran ruby; and typed posts(:one)\n^d and it said exactly what I'm thinking; "undefined method `posts' for main:Object (NoMethodError)" At least someone is sane around here ^_
<lmat>
I did the same thing in irb and it says the same thing :-)
<lmat>
I learned Python a couple weeks ago and it wasn't too bad. This is really frustrating!
<lmat>
I keep thinking, I'll just look at a beginners' tutorial to get started, but they really suck (at least for me).
<lmat>
They say "look how easy this is! just type posts(:one) and it gets one post! wowie!" without telling what's happening :(
Swyper has quit [Remote host closed the connection]
<adam12>
lmat: Also, when you say learned Python; you mean just Python and not Django or something? Because right now you're learning Rails and not Ruby. Rails has many conveniences which you need to learn. That's not directly related to Ruby.
<lmat>
adam12: pry, right, thanks for reminding me.
<lmat>
adam12: Good point. I learned flask hand in hand with python. Web frameworks are often pretty invasive (changing the way the language feels) and rails seems particularly invasive.
<adam12>
lmat: Call binding.pry beside the line you're curious on. Once you're there, use the `?` pry helper to look at things. try `? posts`.
<al2o3-cr>
that any? should of been in the lambda, oh well.
<adam12>
lmat: For Flask equivalent you'd be in Sinatra or Roda land. But neither of them afford you many conveniences out of the box (and Roda explicitely forces you to configure it how you want it through it's plugin system)
<adam12>
lmat: Pry is your best tool to learn. There's some screencasts on the pry website that talk about inspecting objects (`cd`, `ls`, etc). It's very powerful.
<lmat>
When trying to run rails test; I get "cannot load such file -- pry" I did gem install pry; before running rails test; I have require 'pry' at the top of my test.
<adam12>
lmat: It will need to be part of your Gemfile. In Rails, use `pry-rails` as the gem name, which will make your rails console load pry too.
suukim has quit [Quit: Konversation terminated!]
<lmat>
adam12: "cannot load such file -- pry-rails" I gem install pry-rails; and it says it installed one gem, but still no cigar.
<adam12>
lmat: It has to be in your Gemfile.
<adam12>
lmat: And skip any `require` that you're doing. Rails will do that for you (it's one of the Rails conveniences).
<lmat>
okay, thanks!
sphex_ is now known as sphex
<lmat>
adam12: Got it! Thanks again! When it broke on the pry binding call, it printed the call site like 8 times. Oh well :-)
chalkmonster has joined #ruby
houhoulis has joined #ruby
fphilipe_ has joined #ruby
sauvin has quit [Ping timeout: 272 seconds]
cadeskywalker has quit [Ping timeout: 258 seconds]
fphilipe_ has quit [Ping timeout: 252 seconds]
TCZ has quit [Quit: Bye Bye]
Nahra has joined #ruby
sgen has quit [Ping timeout: 240 seconds]
<lmat>
adam12: You've been so helpful, thank you! al2o3-cr you, too!!
<adam12>
lmat: cheers! and good luck.
<al2o3-cr>
;) np
lineus has quit [Remote host closed the connection]
lineus has joined #ruby
cadeskywalker has joined #ruby
axsuul has quit [Ping timeout: 258 seconds]
<lmat>
FOUND IT!!! It's a fixture and defined in ./test/fixtures/posts.yml
troulouliou_dev has quit [Quit: Leaving]
<lmat>
This reminds me a bit of java (spring boot). A little spaghetti-ish ^_^ I'm sure after I know all the little conventions and gotchas, it will be very comfortable. It's very uncomfortable now ;-)
<lmat>
I found it using pry-nav and stepping into the posts function and inspecting all the variables.
Xiti` has joined #ruby
Xiti has quit [Ping timeout: 260 seconds]
axsuul has joined #ruby
subfj has joined #ruby
shirak_ has joined #ruby
anveo has joined #ruby
ctOS has joined #ruby
xxdxxd has joined #ruby
gix has joined #ruby
Bounga has quit [Ping timeout: 272 seconds]
xxdxxd has quit [Quit: xxdxxd]
xxdxxd has joined #ruby
gix- has joined #ruby
gix has quit [Disconnected by services]
Pika has quit [Remote host closed the connection]
brool has joined #ruby
tdy has joined #ruby
subfj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ursu has joined #ruby
mokha has joined #ruby
<gitter1234>
Hello! Trying to make it so that only users approved by admin can post posts. I've created a corresponding controller action which I'm attempting to call from the view, but how come I'm getting undefined method? https://gist.github.com/1234dev/0f37e7935bf2efe85070bd1a7786d1a4
mossplix has quit [Remote host closed the connection]
subfj has joined #ruby
phaul has joined #ruby
weeirc8087 has joined #ruby
yokel has quit [Ping timeout: 272 seconds]
Ai9zO5AP has quit [Quit: WeeChat 2.5]
bvdw has quit [Quit: bvdw]
<leftylink>
don't think it's possible to tell from that code, since we don't see any calls to toggle_approved there, only the definition
bvdw has joined #ruby
jenrzzz has joined #ruby
yokel has joined #ruby
subfj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mossplix has joined #ruby
<gitter1234>
leftylink: sorrry its kinda messy, fixing it up now. "toggle_authorized" is supposed to be "toggle_approved"
sameerynho has joined #ruby
<gitter1234>
also making a route
<lmat>
I'm seeing undefined method log_in_as in my integration test. https://stackoverflow.com/questions/37173150 makes reference to it, but I can't find any documentation for log_in_as in the rails docs.
<lmat>
Oh, ... maybe I'm supposed to write that method!
mossplix has quit [Ping timeout: 272 seconds]
AJA4350 has quit [Ping timeout: 272 seconds]
Jonopoly has joined #ruby
Fernando-Basso has joined #ruby
tpanarch1st has joined #ruby
subfj has joined #ruby
AJA4350 has joined #ruby
<adam12>
gitter1234: Forget about using `helper_method :toggle_approved`. It's not needed.
lineus has quit [Ping timeout: 240 seconds]
weeirc8087 has quit [Ping timeout: 258 seconds]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<adam12>
gitter1234: Your link_to in the view should have a route helper for the second argument, taking the _user_ as the argument (not the current_user, lest you want to disable yourself)
lineus has joined #ruby
subfj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oncall-pokemon has quit [Quit: Connection closed for inactivity]
FernandoBasso has joined #ruby
Fernando-Basso has quit [Ping timeout: 240 seconds]
<gitter1234>
its looking pretty nice and clean now
mossplix has quit [Remote host closed the connection]
<gitter1234>
adam12 you've been in here helping people all day lol. you deserve the rest of the day off :D and a medal of honor :D and cases upon cases upon cases of beer
subfj has joined #ruby
mossplix has joined #ruby
subfj has quit [Client Quit]
Nahra has quit [Quit: leaving]
Swyper has joined #ruby
<lmat>
What's the normal way to log in during an integration test?
<lmat>
I've tried several things...maybe I need to put a password hash in my fixture? yuck
<lmat>
hmm...maybe I can set the session information on my first requets...
Pika has joined #ruby
<Pika>
More builder questions D:
<Pika>
Is there like... a way to add attributes to an XML tag after the fact or from inside the { |xml| curly brace thingies }
lucasb has quit [Quit: Connection closed for inactivity]
Swyper has quit [Remote host closed the connection]
abe has quit [Quit: Leaving]
<gitter1234>
adam12: for what its worth, this seemed to work: user = User.first; user.avatar.attach(io: File.open('public/apple-touch-icon.png'), filename: 'apple-touch-icon.png')