|
Dr. Krieger posted:This is perfect, the only thing I'd add is that of you only need your monkey patch in a few specific places is take a look at refinements. They are very weird because of how they handle scoping but they do work well when you need an explicit extension on a base class in only a few places and allow you to easily remove them later over just patching globally of you find a cleaner solution. Yes, good call. I've had mixed results with refinements, but a couple of those times they were awesome. Worth consideration.
|
# ? Jul 27, 2019 04:00 |
|
|
# ? May 14, 2024 10:53 |
|
kayakyakr posted:Good response. What was sending this request was a hardware device (Android), so I put it on the radar for the Android dev team to send me some examples of how that payload is prepared and sent over. In the meantime, I found I was able to address the issue by building a serializer to handle the problematic JSON and JSONB-powered fields. Working through some test cases now to see how it holds up.
|
# ? Jul 29, 2019 14:28 |
|
GeorgieMordor posted:What was sending this request was a hardware device (Android), so I put it on the radar for the Android dev team to send me some examples of how that payload is prepared and sent over. It should be the same as any other web request, unless it’s a matter of rendering on mobile.
|
# ? Jul 29, 2019 14:50 |
|
Rails 6 went official yesterday: https://weblog.rubyonrails.org/2019/8/15/Rails-6-0-final-release/
|
# ? Aug 16, 2019 20:07 |
|
kayakyakr posted:Rails 6 went official yesterday: https://weblog.rubyonrails.org/2019/8/15/Rails-6-0-final-release/ Which puts our massive codebase completely out of any support. God I need a new job.
|
# ? Aug 19, 2019 02:31 |
|
The Journey Fraternity posted:Which puts our massive codebase completely out of any support. what kind of job is this that has all the rails but not wants to upgrade it
|
# ? Aug 19, 2019 04:53 |
|
Sivart13 posted:you don't want your job to be upgrading the massive codebase to Rails 6? I would love to, if it weren't such a behemoth undertaking even to get it to 5.0. This codebase predates every single engineer, and was originally written by PHP devs writing their first Rails app.
|
# ? Aug 19, 2019 06:22 |
|
The Journey Fraternity posted:I would love to, if it weren't such a behemoth undertaking even to get it to 5.0. This codebase predates every single engineer, and was originally written by PHP devs writing their first Rails app. 1) you do need a new job 2) I don't have much empathy, at least for your company, because you didn't spend any time maintaining your codebase. If you had followed along with rails versions, it wouldn't be such a massive undertaking. The longer you put it off, the more painful it will become. Also, Rails 4 to rails 6 isn't so hard. The codebase was mature enough by Rails 4.2 that there aren't many barriers to changing over.
|
# ? Aug 19, 2019 15:26 |
|
I'm stuck with using ActiveAdmin for a thing. It's fine, but when you're trying to do some more complex bits it gets really annoying. I have two models associated via a join table. This join table was created using a migration, and while it has a working table and associations, does not have its own class in the Rails app. Maybe an issue? So, schema is something like this: systems(:id) -> systems_users(:system_id, :user_id) -> user(:id) What I'm trying to do is alter a User form so that the joined records can be added / removed from within ActiveAdmin. I'm going around in circles trying to get this to work -- the only successful way I've been able to do this is by building a giant multi-select element, which will add and remove associations appropriately but is garbage for UI. Alternately, ActiveAdmin shows these easily enough when using a has_many within the form, but it then changes the structure of the parameters on submit. Displays and saves, but horrible to work with: code:
code:
When submitting I see a :systems_attributes parameter going through, which contains an array of ambigious :ids and values. GeorgieMordor fucked around with this message at 19:56 on Aug 21, 2019 |
# ? Aug 21, 2019 18:34 |
|
kayakyakr posted:1) you do need a new job Oh for sure, I have none for them either. This place is very reactionary and only upgrades when things fall out of security fix windows, giving no time to do it outside of that small window. (I'll stop the derail here)
|
# ? Aug 21, 2019 22:40 |
|
How many Systems are there? Could you get away with checkboxes? code:
I'm a little fuzzy on this because I mostly avoid HABTM without an explicit join table model, but I think you would need one to use ActiveAdmin's has_many -- because you're essentially accept_nested_attributes_for'ing SystemsUsers
|
# ? Aug 21, 2019 23:17 |
|
The Milkman posted:How many Systems are there? Could you get away with checkboxes? Sadly, no. Check boxes worked, but the System records are already over a couple hundred and will continue to grow. Honestly I did humor the idea just to save my sanity but the next issue was thinking about how to render the markup as columns and not just one vertical insane list of checkboxes. The Milkman posted:I usually go for the multiple select widget, but wrapped in something like https://select2.org/ to make it sane to work with. It also opens the door to dark magicks like using it to dynamically search & populate against ActiveAdmin's built in Ransack support for when you get into the hundreds/thousands+ of records scale. Was about to do this too, though paused because this admin portion is used only by internal employees, and maybe 2-3 max at that, so principally I was getting annoyed tying in a jQuery plugin just for a single select form. No hate on Select2 -- that's actually been going strong for a while now. To your point re: HABTM, yes it's a bit puzzling it's set up this way. Historically I've done my join tables defined as models themselves similar to how you've described, and created their migrations accordingly. I didn't even know there was a "Rails" way of creating a join_table migration until I poked through the migration files.
|
# ? Aug 22, 2019 15:55 |
|
Partycat posted:I have been working on developing my internal toolset in ruby and rails, and have been slowly improving with my techniques, built my own internal gem for some modules, etc quote:Python immediately turned me off by being column/space dependent giving me COBOL flashbacks, was really hoping not to have to deal with that poo poo or line terminators ever again. Im an ex-COBOL coder too. So I feel you on this one. But overcome it. Ive been using python since the 90s and its a genuinely great little language. Its got its downsides, I wish they'd adapt rubys closures, but its a mature, comfortable language wth some genuinely great libraries. Well unless the hipsters get bored and leave a trail of library corpses as they shfit to, i dunno , loving Golang or something. And while Rails is pretty fun to work with, Django's ORM blows pretty much the entire field of its competitors out the water. Class based views are a clusterfuck though.Rail's Spec is peerless though. Best testing system ive ever worked with duck monster fucked around with this message at 13:45 on Oct 4, 2019 |
# ? Sep 14, 2019 17:50 |
|
duck monster posted:Unpopular opinion, but yes. Ditto with Node JS. The jobs have been drying up as companies move across to python, and a LOT of pretty important libraries seem abandoned now. I disagree. I think Rails is holding steady as a fantastic low-risk language for startups and I found plenty of jobs out there for senior devs. It's biggest competitor is not python, but instead NodeJS which is still getting a lot of new startup work. I feel that Python is tending to carnivorize more and more of Java and Microsoft's markets. Depending on which metrics you track, Ruby's been up or at least holding steady YoY. There are some old libraries that seem abandoned, but I prefer to think of them as "mature"
|
# ? Sep 15, 2019 02:56 |
|
Rails is as good as ever, it just moved from "new and trendy" to "old and reliable"
|
# ? Sep 15, 2019 14:36 |
|
edit: whoops identity leak
duck monster fucked around with this message at 16:01 on Oct 10, 2019 |
# ? Oct 4, 2019 13:41 |
|
I have a Capybara test that passes locally, but fails intermittently (almost always at the moment) on our CI. The test clicks on a link to open a menu, then clicks on a link on the menu. That menu link isn't visible, and I don't know why. Does anyone have any suggestions of something I could try? Here's roughly how the test works: code:
I can comment out/delete this test - it's just verifying that a menu link works - but I'd like to fix it if I can.
|
# ? Oct 31, 2019 20:27 |
|
What drivers do you use to run capybara? Is resolution configured the same on CI and locally? It is possible that the browser resolution is different on CI and the button is hidden at that resolution. However I would expect the test to fail every time on CI in that case. Also are you using ajax to load the button?Might be an issue there too.
|
# ? Nov 1, 2019 18:23 |
|
We had an issue once where resizing the window during a test caused it to fail intermittently in CI. That was fun.
|
# ? Nov 1, 2019 20:52 |
|
Pollyanna posted:We had an issue once where resizing the window during a test caused it to fail intermittently in CI. That was fun. We had to abandon AWS' device farm because randomly it wouldnt open the app, and instead just click on random poo poo. Actually it almost never did. loving useless
|
# ? Nov 2, 2019 11:58 |
|
so im working on a coding practice, using an api for a random name and another api for a random joke. im supposed to be able to create an api that generates this new joke on create. it will be tested by using curl. so i gotten all of the parts working, creating the new joke, gettinn CRUD to work for my api. the only thing is, im trying to get my method (for creating the new joke) to run when i create a new instance of the model. it is not working. is running methods in the create method common? is there a different way i should be thinking about this? should i be having the user run the method on create manually? this seems wrong but im not finding a ton on google for running a method for params on create.
|
# ? Nov 14, 2019 21:38 |
|
Edgar Allan Pwned posted:so im working on a coding practice, using an api for a random name and another api for a random joke. im supposed to be able to create an api that generates this new joke on create. it will be tested by using curl. You can either use a service pattern or a before_create callback. You can also make a fat controller because WGAF and call out to the API there. Depends on what all is involved in generating a new joke. Is it calling a separate api? Is it calling a machine learning algorithm? Asking a contractor overseas?
|
# ? Nov 15, 2019 00:03 |
|
I have two models with a relationship similar to this:code:
code:
|
# ? Jan 14, 2020 13:00 |
|
Is there a reason you can't do code:
|
# ? Jan 14, 2020 17:18 |
|
I'd probably build it wherecode:
|
# ? Jan 14, 2020 18:06 |
|
The Milkman posted:Is there a reason you can't do The Milkman posted:Is there a reason you can't do Thanks guys. I ended up flipping the relationship (so that suit belonged to card) as it made more sense for my use case and that ended up solving the issue.
|
# ? Jan 15, 2020 12:02 |
|
Tea Bone posted:Thanks guys. I ended up flipping the relationship (so that suit belonged to card) as it made more sense for my use case and that ended up solving the issue. So you have... 4 suits per card and 13 suits per deck? Interesting setup indeed...
|
# ? Jan 15, 2020 16:14 |
|
I'm almost certain that the problem is that you don't have `inverse_of` in the relationship definition, this is common gotcha, but I didn't test it This (pretty old) article says that you need inverse_of when specifying conditions/scopes xtal fucked around with this message at 23:24 on Jan 29, 2020 |
# ? Jan 29, 2020 23:22 |
|
I've been working with Rails for a very long time, and I have a new side project I'd like to do that's very data input heavy, and I absolutely cannot face setting up all the controllers and such. Is there a nicer way to do it than either grinding through it or using the scaffolding generators? Anything nice and dynamic that doesn't immediately fall apart? I'm just so tired.
|
# ? Feb 26, 2020 22:52 |
|
Jaded Burnout posted:I've been working with Rails for a very long time, and I have a new side project I'd like to do that's very data input heavy, and I absolutely cannot face setting up all the controllers and such. Is there a nicer way to do it than either grinding through it or using the scaffolding generators? Anything nice and dynamic that doesn't immediately fall apart? I mean, are you looking for admin interfaces like rails-admin? Or are you looking for, say a CMS backend like Contentful or Kentico? Or, if you need to roll something yourself, this looks like a fun way to get a quick data server going and being GraphQL it's decidedly NOT rails: https://evilmartians.com/chronicles/graphql-on-rails-1-from-zero-to-the-first-query
|
# ? Feb 26, 2020 23:13 |
|
kayakyakr posted:Or, if you need to roll something yourself, this looks like a fun way to get a quick data server going and being GraphQL it's decidedly NOT rails: https://evilmartians.com/chronicles/graphql-on-rails-1-from-zero-to-the-first-query I've used this for a client project and it's just about the opposite of what I'm after since yes you only need one controller but you need to create equivalent queries and mutations for everything plus a whole JS frontend. kayakyakr posted:I mean, are you looking for admin interfaces like rails-admin? This, however, is exactly the sort of thing I was looking for. Looks like there's rails-admin, activeadmin, and administrate available. I'll probs try out administrate. Thanks!
|
# ? Feb 26, 2020 23:59 |
|
Has anyone upgraded to Xcode 11.3.1 recently and -- no surprise -- had it bork their Rails environment? I'm working on 2 separate Rails 6 apps right now, and one symptom in both of them is my console seemingly failing on proper output with ActiveRecord. I am given zero errors in any respect -- have absolutely no idea what could be causing this. Both apps run fine in both dev and all live environments (stag, prod, etc) on their respective servers. Here's an example: code:
- Re-installing readline - Re-installing local Ruby version - Re-installing Rails gem Suspicion is of course something isn't getting pointed to properly, but there is absolutely no errors indicated what that might be anywhere. EDIT: Some further insight. Looks like behind the scenes everything is working, just not outputting as expected. For example, adding a puts declaration outputs what the console did historically / normally. Still no idea what is going on or why. Example: code:
GeorgieMordor fucked around with this message at 14:11 on Mar 23, 2020 |
# ? Mar 20, 2020 18:57 |
Does anybody have any recommendations for resources I can use to learn Rails v5.1+ ? All the popular tutorials out there seem to be with older versions (from 2011 -> 2017 commonly) which have some pretty noticeable differences to what the latest Rails documentation offers (which seems pretty light on details, somehow??) and I'm not sure what differences are significant and which aren't. I'm doing a test run on building a project and working on it, and I'm running into all sorts of hosed up issues with model objects not being passed to the form and so forth, and I have no idea what I've done wrong or why. But when comparing to github repos and written/video tutorials and the base documentation, I see a whole bunch of different ways to do things and it's not really clear why there are differences or how important they are. For example: railscasts.com - latest episode was 2013, 7 years ago gorails.com - recent episodes seem to be aimed at very specific, more advanced topics, and the base/intro episodes are all from 2014 or so driftingruby.com - seems to be aimed at more advanced topics railstutorial.org - was published in 2010, no mention if it's been updated since then and youtube most of the videos seem to be 2017 at the latest and from people who are learning it themselves, so they dont have good explanations of why theyre doing what theyre doing Sulla Faex fucked around with this message at 09:42 on Mar 28, 2020 |
|
# ? Mar 28, 2020 09:37 |
|
Sulla Faex posted:railstutorial.org - was published in 2010, no mention if it's been updated since then It says in the first sentence below the title that it was updated for Rails 6. Also https://guides.rubyonrails.org/ these are up to date.
|
# ? Mar 28, 2020 10:48 |
|
The two biggest sea changes in Rails have been 1 -> 2 and 2 -> 3, beyond that it's a much more incremental change, so as long as you're taking the broad concepts from your reading and not latching on letter by letter then you'll find value in anything written for 3+. https://api.rubyonrails.org is my go-to resource for hyper specifics, and the guides are a decent introduction though I find them in a muddy middle ground between doc and guide.
|
# ? Mar 28, 2020 11:06 |
|
PragProg’s Rails 6 book has been a nice re-introduction for me, since my professional experience was mostly around Rails 4 and I’m hopping back in. https://pragprog.com/book/rails6/agile-web-development-with-rails-6
|
# ? Mar 28, 2020 15:31 |
|
Basically, from Rails 4 and on, from an outward facing perspective, it's been just adding new core libraries to tackle various areas: ActiveJob (background jobs), ActiveStorage (file uploads), ActionText (rich text editing), ActionMailbox (receiving email) and probably others I'm forgetting. Any of the concepts from oldish material will still largely still apply, maybe some minor syntax tweaks. There are some big changes like System Tests (browser testing) you'll want to use, and others you may want/need to deal with like Webpacker. The PragProg Rails book is up-to-date and excellent. I also recommend whatever the latest edition of Rails Test Prescriptions by Noel Rappin is.
|
# ? Mar 28, 2020 17:23 |
Thank you for the replies! I think my issue is that the syntax keeps changing between the material I was using to learn it, and whenever I tried to follow one example precisely, it wouldn't work on the MVC level without significant experimentation and changing, and it was getting really hard to track why people were doing anything or why one thing was working and one wasn't. I think I'll get the PragProg book and start from scratch with that
|
|
# ? Mar 29, 2020 11:56 |
I'm running into a problem with creating conditional unique validations in the model/db. I have three relevant columns in a model, "user_id", "city_id", and "active". I'm trying to create two validation checks: 1. each user_id and city_id pair must be unique 2. each user can have only ONE row where active=1 1 is working fine, but 2 I can't get to work. My model file: code:
code:
Because the error I consistently get when trying to create a new city_player is: quote:SQLite3::ConstraintException: UNIQUE constraint failed: city_players.active, city_players.user_id: INSERT INTO "city_players" ("city_id", "user_id", "created_at", "updated_at") VALUES (?, ?, ?, ?) Which makes me think the DB is just validating on "is user_id and active the same? (regardless of the value of active)" Incidentally, I'm using rails_admin as an easy DB workbench and nothing I can do is able to get it to show all columns in city_players, i.e. "active" doesn't show at all, despite it showing in the actual DB via dbconsole. Sulla Faex fucked around with this message at 15:55 on Jun 9, 2020 |
|
# ? Jun 9, 2020 15:52 |
|
|
# ? May 14, 2024 10:53 |
|
OK, so first off `if: Proc.new {|city_player| city_player.active?}` can be replaced with `if: :active?`. Secondly, it feels like this is a good candidate for a custom validation, rather than trying to push the envelope of the uniqueness validation. Thirdly, yes you're correct that unique indexes DB-side are a simpler logic. If you want something more complex DB-side then you need something like a "check constraint", which may or may not be available in sqlite.
|
# ? Jun 9, 2020 16:35 |