« first day (1649 days earlier)      last day (1606 days later) » 

 
5 hours later…
11:10 AM
I really dislike heavy handed tactics in UI - like making it so someone can't undelete stuff or edit their comments. I definitely see the need for it in like - selling stuff though - to prevent people from manipulating things / sales to their advantage & cheating people.
also...i'm just bored enough of everything else, making a cow facebook sounds like a fun idea if we can get facial recognition trained on them for feeding & milking processes :)
 
12:08 PM
Do you know how I could delete based on multiple columns in Rails ?
 
just chaining .where statements to get the right conditions for column names, then .delete_all
Post.scope1.scope2.delete_all
Could do compound scope too - where both columns you're filtering based on before deleting are contained within a single parent scope (if you're feeling fancy - they can lead to issues).
Alternatively, Post.where(first condition).where(second condition).delete_all
 
User.where("(name, email) IN (?)",
sorry didn't get to press enter
has to be like in an array
this touple form
tbh i never had to do this
> <
but if i giev an array like [[name1, email1], [name2, email2]]
it doesn't work
 
I've used tuples in python - but not sure what you're asking ... see this specific section for the where clauses ... guides.rubyonrails.org/active_record_basics.html#delete
Oh, that kind of makes more sense at the - that's enumerable in array
 
```FlyInTools::Event.
where("(external_id, fly_in_tools_fly_in_id) IN (?)", data.map { |item| [item.external_id, @fly_in.id]}).
destroy_all```
something like this
oh well doesn't matter :D
 
cntrl+k ... no special chars to format btw :)
So the array idea works best after you have determined the ID of the row you want to delete.
You absolutely should not be mapping against the db unless you're solid on testing it ahead of time in dry runs. Saw one guy drop his company to their knees last year doing that one
 
12:27 PM
lol, really ? :))
 
Yea - as happens, their onsite backup tapes weren't usable for w/e reason - so first he locked up the server to db, then when they finally interrupted the threads, it messed with the transaction wrapper & they supposedly had some misconfiguration so sql db didn't just rollback automatically ... like 5 or 6 bad decisions in a row
by the time we learned about it - too late
I'm a fan of using pluck/find/where to construct an array of ID's to call delete against. Much neater & allows me to see what will be nuked first!
so in that aspect you run the same setup in some ways, but it gets stored in variable you can play with or post to file etc with details if pluck it that way
pluck is your multi-column best friend for getting single rows in my opinion - though where clauses work better if it's a range of numbers or conditions which line up well
Actually nevermind - I forgot pluck doesn't allow array input ... have to select
The other reason I like pulling those ID's into an array or just using a variable to collect all the activerecord objects then calling delete against that set is you are importing this information from a file ... pulling them first to ensure there is no data corruption is huge, though AR supposedly should safety most of your stuff from script
 
1:24 PM
omg ... so I've been doing closed system style pundit auth ... which relies on trapping the user not signed in the initialization of the class or the scope class inside it. Well, it's killing me on the main page where people don't need to sign in ... but if I pull that - I have to figure out how to check the user exists efficiently ... instead of throughout the entire class like 57 places
thank lord for advanced copy & paste in c9 ... I hate trying to kick off vim & remembering the commands for their version
 
1:53 PM
odd, when not signed in - there are certain records which the edit button still appears for ... which shouldn't happen since I set edit permissions to false for everyone as a test
interesting, my it turns out there were 2 entries that were orphaned when I manually assigned a record in there to another user
 
 
4 hours later…

« first day (1649 days earlier)      last day (1606 days later) »