Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
If it's anything like my business emails won't work, because the real problem is that the executives think the spambots are all real people who need to be on boarded and get mad when you tell them they're not.

Adbot
ADBOT LOVES YOU

aunt jenkins
Jan 12, 2001

necrotic posted:

Email verification? If you don't want emails then captchas may be your best option.

The problem is that the bots will use real people's emails to signup (I have no idea why or how this benefits the bot author but w/e) and then those people rightly mark your confirmation you sent as spam and your email provider gets pissy. So email confo alone won't really solve the problem.

kayakyakr
Feb 16, 2004

Kayak is true
I have a dream of rails meets JS like https://docs.stimulusreflex.com/, but with a svelte backing instead of stimulus because.

That said, stimulus reflex does look cool

Gmaz
Apr 3, 2011

New DLC for Aoe2 is out: Dynasties of India
I use stimulus for non SPA purposes with my rails projects and I must say I really enjoy it. It's very simple to use, and anyone familiar with JS can pick it up super quickly. Even someone primarily backend oriented like me.

kayakyakr
Feb 16, 2004

Kayak is true

Gmaz posted:

I use stimulus for non SPA purposes with my rails projects and I must say I really enjoy it. It's very simple to use, and anyone familiar with JS can pick it up super quickly. Even someone primarily backend oriented like me.

Yeah, I just don't like working with the DOM like that. A well put-together React/Vue/Svelte project brings a lot of that Rails joy to the front end world, and Stimulus just doesn't do that for me.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
Funny, I've spent the last few weeks ripping Vue poo poo out of a project and replacing them with some Turbo Streams and little bit of glue code in Stimulus. Granted much of it only marginally needed to be Vue components in the first place - but boy it felt good to rip out the endless heaps of JSON serializer/init code and replace it with "you know what just render this partial and it just updates this div here it's fine actually"

enki42
Jun 11, 2001
#ATMLIVESMATTER

Put this Nazi-lover on ignore immediately!
Yeah, we're in the process of moving over to Turbo (not even streams yet, just "go grab this partial and shove it here" with frames), and it's pretty great, it's like a well-thought out version of buggy code I've hacked together tons of times to load part of a view through AJAX.

kayakyakr
Feb 16, 2004

Kayak is true
Yeah, there are definitely easy ways to screw up JS frameworks. Another former coworker is advocating for going in on React + GraphQL-Ruby

Peristalsis
Apr 5, 2004
Move along.
I added render_async to a multi-tabbed page, to let a couple of tabs load in the background while the rest of the page is viewable. This worked okay, except for one thing - there's a collapsible panel at the bottom of each tab that loads in a collapsed state, and won't open when clicked on in the new branch.

I'm not very good with JavaScript (and I've never looked at coffeescript at all), but I've been able to determine that the coffeescript method used to open and close the panel isn't firing any more for the tabs I changed. It still works okay on tabs I didn't modify. I'm assuming there's some issue with the script not hooking up with the haml code properly due to the asynchronous loading, but I really have no idea what to do from here. There are no JS errors showing in the browser when I click on the non-responsive panel. If anyone has any suggestions or even useful background info, I'd be grateful.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

This is the kind of thing I would hop on a screen share call for. But it’s basically you’re at the point that you need to learn the chrome or Firefox debuggers and how to set breakpoints in your front end

Dm me tomorrow if you’re still having issues I can try to help

enki42
Jun 11, 2001
#ATMLIVESMATTER

Put this Nazi-lover on ignore immediately!
Also, I know this doesn't directly solve your problem, but we recently subbed out render_async for Turbo, and it's a way smoother experience IMO (it also natively supports things like not loading a tabs content until it's visible in the DOM, so you can take a lot of that javascript work off your plate).

But even in the render_async world, you need to make sure that whatever page initialization code you might run listen for an event indicating that the page has loaded, and then run them. If you're using render async with turbolinks, it will fire a "turbolinks:load" event on the document. In our codebase, we set up a list of events to be run on pageload, and then trigger them with this (we're using turbo instead of turbolinks, but this all works the same with a different event name):

code:
document.addEventListener('turbo:load', () => {
  events.pageload.forEach(event => event.call());
});
(and then any page can register an event to be run on pageload)

enki42 fucked around with this message at 13:32 on Feb 19, 2021

Peristalsis
Apr 5, 2004
Move along.

A MIRACLE posted:

This is the kind of thing I would hop on a screen share call for. But it’s basically you’re at the point that you need to learn the chrome or Firefox debuggers and how to set breakpoints in your front end

Dm me tomorrow if you’re still having issues I can try to help


enki42 posted:

Also, I know this doesn't directly solve your problem, but we recently subbed out render_async for Turbo, and it's a way smoother experience IMO (it also natively supports things like not loading a tabs content until it's visible in the DOM, so you can take a lot of that javascript work off your plate).

But even in the render_async world, you need to make sure that whatever page initialization code you might run listen for an event indicating that the page has loaded, and then run them. If you're using render async with turbolinks, it will fire a "turbolinks:load" event on the document. In our codebase, we set up a list of events to be run on pageload, and then trigger them with this (we're using turbo instead of turbolinks, but this all works the same with a different event name):

code:
document.addEventListener('turbo:load', () => {
  events.pageload.forEach(event => event.call());
});
(and then any page can register an event to be run on pageload)


Thanks! As I was showering this morning, it occurred to me that the problem might be that the JS that isn't firing is in a document ready or document loaded event handler, and since the page is already loaded when the async call is made, it isn't getting attached to the new parts of the page correctly. I don't think we're using turbo* - will something like this still work?

Edit: The Using Default Events section of the documentation looks promising. When all else fails, read the rest of the instructions, eh?

Peristalsis fucked around with this message at 16:11 on Feb 19, 2021

Tea Bone
Feb 18, 2011

I'm going for gasps.
I'm trying to track the number of live users on my web app.

When a user connects to the app they subscribe to a "live users" action cable channel. I have a "Live Users" index on the admin back end.

Initially, I had it so when the admin went to the live user index the server would get the number of connections on the live users channel from Redis and use that to populate the index. Then any new subscriptions to the live user channel would broadcast to an admin channel and get added to the index. After running it like this for a few hours on my dev server things would start slowing down, and since I don't know too much about Redis or what's going on under the hood I switched to a different method.

My current solution, I have a live user model, on subscription to the live user channel a new record is created (and then removed on unsubscribe). Then the index page simply queries the database for current live users. This is working great on my dev server and has the added benefit of being able to add extra data about the connection (IP, browser language, current page etc) but it feels like there is a lot of database overhead here and I'm not sure how well it will work for production.

Does anyone have any suggestions how I can better handle this?

kayakyakr
Feb 16, 2004

Kayak is true

Tea Bone posted:

I'm trying to track the number of live users on my web app.

When a user connects to the app they subscribe to a "live users" action cable channel. I have a "Live Users" index on the admin back end.

Initially, I had it so when the admin went to the live user index the server would get the number of connections on the live users channel from Redis and use that to populate the index. Then any new subscriptions to the live user channel would broadcast to an admin channel and get added to the index. After running it like this for a few hours on my dev server things would start slowing down, and since I don't know too much about Redis or what's going on under the hood I switched to a different method.

My current solution, I have a live user model, on subscription to the live user channel a new record is created (and then removed on unsubscribe). Then the index page simply queries the database for current live users. This is working great on my dev server and has the added benefit of being able to add extra data about the connection (IP, browser language, current page etc) but it feels like there is a lot of database overhead here and I'm not sure how well it will work for production.

Does anyone have any suggestions how I can better handle this?

Honestly, that kind of database overhead isn't bad at all. The other thing you might try is not deleting records, just keeping them around and updating sub/unsub dates.

You could also go to a key:value store that might be a bit faster than postgres with the same benefits of having that on the DB.

Tea Bone
Feb 18, 2011

I'm going for gasps.

kayakyakr posted:

Honestly, that kind of database overhead isn't bad at all. The other thing you might try is not deleting records, just keeping them around and updating sub/unsub dates.

You could also go to a key:value store that might be a bit faster than postgres with the same benefits of having that on the DB.

Thanks. I just wanted to check I wasn't breaking some cardinal sin by adding and deleting rows that much. After doing a bit more research into Redis, I think a key:value store is probably the best way forward but I'm happy to push that down the line for the time being as the database method is working fine.

Peristalsis
Apr 5, 2004
Move along.
Never mind, I'm an idiot.

Peristalsis fucked around with this message at 21:00 on Apr 19, 2021

pliable
Sep 26, 2003

this is what u get for "180 x 180 avatars"

this is what u fucking get u bithc
Fun Shoe
Any recommended modern Ruby and/or Rails guides? Gotta learn Ruby and Rails for a possible job! And I need to work! I know how to program, so something akin to K&R would be nice, unless the reference book Matz wrote like 12 years ago is still good? Seems like everything that was written was 10+ years ago...but new versions of the language are out, so uhh...there has to be updates, right?! Thank you much :)

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

pliable posted:

Any recommended modern Ruby and/or Rails guides? Gotta learn Ruby and Rails for a possible job! And I need to work! I know how to program, so something akin to K&R would be nice, unless the reference book Matz wrote like 12 years ago is still good? Seems like everything that was written was 10+ years ago...but new versions of the language are out, so uhh...there has to be updates, right?! Thank you much :)

As long as it covers Ruby 2.0+ you should be fine. And even then there's not THAT huge of a difference. Why's Poignant Guide was old when I got into Ruby and I'm sure it's still a good reference.

Agile Web Development with Rails gives you an intro to Ruby and Rails, up to date on both, as well as stepping through building a full application.

Rails Test Prescriptions also from pragprog is good for learning Rails from a TDD perspective.

Practical Object Oriented Design in Ruby and Eloquent Ruby are still standards for Ruby Mindset.

If you're just looking for straight reference material,
The guides and API docs ought to get you there.

pliable
Sep 26, 2003

this is what u get for "180 x 180 avatars"

this is what u fucking get u bithc
Fun Shoe

The Milkman posted:

As long as it covers Ruby 2.0+ you should be fine. And even then there's not THAT huge of a difference. Why's Poignant Guide was old when I got into Ruby and I'm sure it's still a good reference.

Agile Web Development with Rails gives you an intro to Ruby and Rails, up to date on both, as well as stepping through building a full application.

Rails Test Prescriptions also from pragprog is good for learning Rails from a TDD perspective.

Practical Object Oriented Design in Ruby and Eloquent Ruby are still standards for Ruby Mindset.

If you're just looking for straight reference material,
The guides and API docs ought to get you there.

Awesome, I’ll take a look at all these! Thank you much! :)

pliable
Sep 26, 2003

this is what u get for "180 x 180 avatars"

this is what u fucking get u bithc
Fun Shoe
Seeking: buddy to talk nerdy to me about Rails/Ruby. Started hardcore diving into it this past weekend and I think I'm getting it, but still learnin'! Slide into my DMs tyvm <3

Slimy Hog
Apr 22, 2008

pliable posted:

Seeking: buddy to talk nerdy to me about Rails/Ruby. Started hardcore diving into it this past weekend and I think I'm getting it, but still learnin'! Slide into my DMs tyvm <3

:justpost:

Gmaz
Apr 3, 2011

New DLC for Aoe2 is out: Dynasties of India
There are dozens of us who still use Rails. Dozens!

kayakyakr
Feb 16, 2004

Kayak is true

no question is too dumb for the rails love-in

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

what would it take to become a rails "expert" do y'all think. my manager wants me to become an "expert" in rails this year but I don't think he really understands what that means either, or is able to quantify it. So I have to invent some kind of metric around this to put on my evaluation for next year basically lol. I already know rails pretty dang good

Cloks
Feb 1, 2013

by Azathoth

A MIRACLE posted:

what would it take to become a rails "expert" do y'all think. my manager wants me to become an "expert" in rails this year but I don't think he really understands what that means either, or is able to quantify it. So I have to invent some kind of metric around this to put on my evaluation for next year basically lol. I already know rails pretty dang good

love to create quantifiable progress

I'd just create a checklist of some basic stuff and like, affirm that you can implement it in Rails, whether it's broader programming concepts (SOLID?) or some more Rails specific stuff like writing an API

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
if it comes with a pay raise, yes you're an expert

pliable
Sep 26, 2003

this is what u get for "180 x 180 avatars"

this is what u fucking get u bithc
Fun Shoe

I can and will do both tyvm sir :colbert:. I figured out my last issue tho, only took like 4 hours and banging my head lol. Rails is v interesting, learning a shitload just using the official guides! I see how Rails can be v easy, especially if you have web programming experience, it's kind of just wiring a lot of poo poo together. Onward!

pliable
Sep 26, 2003

this is what u get for "180 x 180 avatars"

this is what u fucking get u bithc
Fun Shoe
I'm trying to just display a very simple static HTML page. I'm obviously missing something incredibly stupid here. Is the incredibly stupid thing that static pages are required to go into the public folder?

In my routes.rb, I have
code:
 root to: "static#index" 
The app is running locally on my machine, it spins up on localhost:3000. My app/controllers/static_controller.rb is so:

code:
class StaticController < ApplicationController

  def index
  end
end
According to the docs, I think, this should just render whatever erb it finds in app/views with the name index.html.erb, right? I go to localhost:3000 on my browser, it sends a GET /, right? Then Rails is supposed to run the 'index' action of the static controller, then render the final page using, Templates, Partials, and Layouts, right? The index.html.erb should be sufficient, right?

Okay so I have one index.html.erb in app/views/static, as well as another one in app/views, both are displaying different poo poo so I can try and differentiate them. In one index.html.erb:

code:
<html>
  <body>
    <h1> welcome poo poo!</h1>
  </body>
</html>
In the other:

code:
<html>
  <body>
    <h1> hello and welcome!</h1>
  </body>
</html>
Nothing is popping up when I go to localhost:3000 though! Refreshing does nothing! Restarting the server (bin/rails server) does nothing! What is the incredibly obviously stupid newbie thing I'm missing here! Please help so I can love the Rails and also get paid to love on Rails thank you <3

EDIT: Even tried changing the html to this:
code:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>This is a purrrrrrrrr</h1>
<p>This is a different thing!!!!!!</p>

</body>
</html> 
And nothing! I feel dumbs please halp!

pliable fucked around with this message at 14:35 on Jul 2, 2021

xtal
Jan 9, 2011

by Fluffdaddy
What are you seeing? A 200 response with no content? If you see a different status code in the inspector like 404 or 406 that would be a hint. What do you see in the rails logs when you're accessing the page?

kayakyakr
Feb 16, 2004

Kayak is true
It was the wrong start script because the app is a React SPA with a rails API, not a traditional rails view app.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
Yeah, the dev server logs in terminal should tell you what controller action was used and what template it rendered. Anything else in your routes file yet? The router works top down and uses the first match it finds so if you somehow had two root calls or something it'll pick the top most one. You can also explicitly specify in your controller action
code:
render "static/index"
to see if something isn't named conventionally

Tea Bone
Feb 18, 2011

I'm going for gasps.
How are you running the server?

Are you using an IDE or magically rubbing it through terminal with "rails s"?

Either way, when you goto localhost:3000, do you see anything happening in the server console? If so, you should be able to see which controller and action the server is routing the request to.

Also, try putting at the end of your static_controller index action:
code:
render inline: 'hello world'
If then "hello world" shows up when you goto localhost:3000 then there's something up with your views.

pliable
Sep 26, 2003

this is what u get for "180 x 180 avatars"

this is what u fucking get u bithc
Fun Shoe

kayakyakr posted:

It was the wrong start script because the app is a React SPA with a rails API, not a traditional rails view app.

Yup, this is the problem! I should have just tried it on the hello world app, but I tried using that as a reference to continue figuring out how all this poo poo works for this particular app, not knowing that this app was an API-only app :cry:.

In the config/application.rb, there is one line that says

code:
config.api_only = true
And so I think Rails does its black magic fuckery at that point to prevent views from happening. Sorry y'all, false alarm, this is why I want a buddy to chat with live and not poo poo up the thread! I'm getting overzealous with all this stuff lol

oliveoil
Apr 22, 2016
I used rails for like a year from 2014 to 2015 and loved it, then switched to Django.

Have there been any big changes to rails since that would make it faster to get something up and running vs Django?

Also I pretty much only ran Django on app engine. Is there something similarly convenient for ruby/rails apps so I don't need to learn like a dozen AWS tools to deploy a rails app or fuss with servers?

enki42
Jun 11, 2001
#ATMLIVESMATTER

Put this Nazi-lover on ignore immediately!
The core is pretty much the same as it was from back then, but there's a lot more nice little side things added:

  • Rich text editing and file storage is baked into the framework
  • Integrating with webpack, yarn, etc. is more built in and easier now - the asset pipeline has mostly gone away
  • There's sprockets and Turbo, which are frontend frameworks / tools that are built around the idea of server rendered HTML - this is more Rails-adjacent than Rails specifically, but they're a thing

I'm sure I'm missing others, and there's probably a billion tiny little things, but for the most part, it will feel pretty familiar to 2015 Rails with a couple "oh, neat!" type things.f

Also if you want straightforward deployment and infrastructure management, there's still absolutely nothing wrong with Heroku for most projects and you're not going to get any easier than that. If AWS is a must, Cloud 66 puts a layer over it (or other cloud providers) that makes it feel like heroku and hides most of the complexity away from you.

kayakyakr
Feb 16, 2004

Kayak is true
2021 Rails has a few neat things that 2015 Rails didn't, and a few issues from 2015 rails still.

Rails 5 launched in 2016, which brought with it the first signs of what modern Rails would be. It came with API-only and ActionCable, which is Rails's native websocket implementation. Both were much needed additions and filled out the feature set.

Rails 6 launched with improvements to the JS environment, bundling webpacker with rails itself. I was trying to get them to go a little further and make it both easy to implement with a js bundler but also agnostic on which bundler you used. It's a little easier to swap out webpack with something else, but not where it should be. DHH's latest thing is Turbo, which is a front-end library that's supposed to feel more rails-y. I don't like it.

OTOH, I do really like the combo library called Stimulus-Reflex, which creates a lite-js, front-end framework that actually does feel rails-y. I would consider it for greenfield projects going forward.

Finally, there's my last annoyance: JSON generation is crap still. ActiveModel::Serializer has 3 active versions, each with annoying-enough-to-not-redo differences in usage. All versions are also slow as hell. Netflix abandoned FastJSONApi. Most of the others have been slow AF. The best I've found for 2021 Rails is a gem called Blueprinter. It's just a hair slower than Fast JSONApi, and more flexible.

All that said: Rails is still a valid language and one of the fastest to get going on. But some of the more unique combos are catching up. I've recently become enamored with SvelteKit + Hasura as a Front/Back combo.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
I've used it on a couple projects now and now that I'm used to the quirks I do like Turbo/Hotwire. That + Github's ViewComponent have really reinvigorated my enthusiasm for sticking with Rails. I'm doing a semi-rebuild of a circa 2014 Rails app and it's very satisfying ripping out a billion messy partials and jquery spaghetti coffeescript and replacing it with a handful of turbo streams that just render an independently testable component.

oliveoil
Apr 22, 2016
Sounds way better than what I was using, Rails 2 because our team was afraid to migrate to Rails 3 iirc.

Really sounds tempting for personal projects. Nearly all my experience has been python+Django on app engine, though, so there's gonna be extra work involved as I have to learn a new platform, one that probably won't take care of as much of the nuisances that App engine did.

Will see if heroku is good. I glanced at it and it seemed like a pain in the rear end but so did app engine when I first used it.

oliveoil fucked around with this message at 00:56 on Jul 28, 2021

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

to be fair migrating 2 to 3 is a huge pain in the rear end

heroku is the opposite of a pain in the rear end

Adbot
ADBOT LOVES YOU

oliveoil
Apr 22, 2016
Yeah, I don't blame them for being afraid. Our stack was about as non-standard as you could possibly get so just getting rails 2 running in the first place was a complicated mess.

And you're making me feel better about my next attempt to try out heroku.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply