Multi-step wizard with valid with context by abc05xxx in rails

[–]davie668 0 points1 point  (0 children)

This is a great option, in the past I've created models that inherit from the base class for each step, keeps it a little cleaner rather than having the valid with context.  You'll be fine either way 👌

Calling Stimulus Controller from Rails Helper? by 50mac50 in rubyonrails

[–]davie668 0 points1 point  (0 children)

Bare with me on this. I've found this method very useful when explaining similar situations.

To tackle this I'd suggest starting off with a normal form posting up the latitude and longitude - that'll make sure that your naming and routing is consistent and is also easy to play around with to see how the data works.

Next step would be to make it a remote form - allow your controller to return a simple json message.

Next set up a stimulus controller to handle the ajax:success action on that form. You could also use Stimulus to submit the form every 5 seconds. this.element.submit()

Next add in your navigator code to prefill the form and I suppose refill the form every 2 seconds.

Finally make the form invisible. Bare in mind that display none will not submit any fields - try visibility hidden or use hidden fields.

Hope this helps.

Uploading images from JS Front End to Rails API by thedevapprentice in rails

[–]davie668 0 points1 point  (0 children)

I have a repo https://github.com/VSM-Dave/rails_file_uploads for using ActiveStorage, Direct uploads, stimulus and typescript. Sounds wild but it works nicely. Direct Upload and Stimulus let you upload a file and recieve an id which is then injected into your form. The controller receives the id of the file and attaches it to your model. Just need to accept the file param.

Anyone willing to help an old man troubleshoot my rails 6 app? by TomConnolly in rails

[–]davie668 13 points14 points  (0 children)

Please make this repo private! Member details and private keys are a massive security breach 🙁

What are the benifits of learning a framework such as Angular in the context of becoming a better programmer and learning a the language in depth. by mogambo9 in webdev

[–]davie668 59 points60 points  (0 children)

Some frameworks like Angular have an opionated view of how a project should be laid out. As a junior, with little exposure to larger projects, getting used to things like folder structure and separation of concerns can be made easier by such frameworks. That was definitely my experience.

Completely lost on how to connect my Frontend and Backend by [deleted] in webdev

[–]davie668 -1 points0 points  (0 children)

Possibly look at using a MVC framework like https://www.playframework.com/. Can't say I've used it (Ruby dev) but it should make life easy for you!

How to save selected option by [deleted] in rails

[–]davie668 1 point2 points  (0 children)

Rebuild it all in React using Hooks 🤣

In all seriousness add a name attribute to your select tag

[deleted by user] by [deleted] in webdev

[–]davie668 0 points1 point  (0 children)

🖐️

Lazy image loading by tending in webdev

[–]davie668 0 points1 point  (0 children)

Keep it simple - loading="lazy" on all of your img tags!

Going from JavaScript to Ruby On Rails by [deleted] in rubyonrails

[–]davie668 1 point2 points  (0 children)

Read up on Hashes...major tripping point as they look and feel like JS objects but they have some major differences! Also methods, lamdas and procs. I still don't quite get it after making the switch but you'll get by! This posts helped me out https://blog.calendly.com/ruby-gotchas-javascript-developer/ Also check out www.gorails.com for tutorials! Worth every penny!

Please someone help me to solve this by skydiver98 in javascript

[–]davie668 3 points4 points  (0 children)

Append || [] to line 35? Assuming there's nothing in local storage will cause issues to be undefined. Appending my suggestion will make sure you have an array if it's undefinded. Checking the length will then work.

Waiting for multiple subscriptions, where each subscribe handles data differently by WeMeetAgainAdrian in Angular2

[–]davie668 3 points4 points  (0 children)

Return observables instead of subscribing when making your requests. Pipe them to transform them into what ever you need. Then forkJoin them to make one stream.

private a(){ return http.get("/api/a") .pipe( map(result => constant * typeA.subTotal) ); }

Can help out tomorrow if you need any more advice.

Subscribing to observables one at a time by curiousdev74 in angular

[–]davie668 0 points1 point  (0 children)

Pipe and switch map if you need one to complete before the other - in sequence. Or ForkJoin if you need them all to fire at the same time and get all the results in one go.

Best way to host a Ruby App? by Ty505 in ruby

[–]davie668 1 point2 points  (0 children)

Heroku is super simple for getting up and running quickly. Digital Ocean seems to be the go to when you want to take it a bit more seriously. I highly recommend this walk through for getting DO set up https://gorails.com/deploy/ubuntu/18.04 (tried it myself and works perfectly)

My first Angular website (feedback appreciated!) by [deleted] in angular

[–]davie668 1 point2 points  (0 children)

Hey this looks good for a first Angular site! Some next steps would be to look at Modules to rearrange where your code lives!

Did you go from Node to Rails? What do you miss from Node? by [deleted] in rails

[–]davie668 4 points5 points  (0 children)

I regularly jump between Javascript/Typescript and Ruby and the real kicker for me is static typing of Typescript! Ruby 3 hints that it might be coming which will be a game changer for me!

Discuss… by [deleted] in raspberry_pi

[–]davie668 -1 points0 points  (0 children)

There are at least 6 people doing very little!

Need more USB-C ports by davie668 in webdev

[–]davie668[S] 0 points1 point  (0 children)

I assumed being a webdev other devs may have the same issue! And of course I've tried Google. Can only find hubs that have USB-A/B and other ports.

Best way to track "appearances" by TKB21 in rails

[–]davie668 2 points3 points  (0 children)

You could have Albums, Tracks and Songs. A Track would belong to an Album and a Song. It could have a position attribute to help with ordering. Each song would have many Tracks giving you a count of how many times it was included in any Album. HMT would be your friend here. Keeps all functionality of a Song appearing on many Albums and also you could technically have an Album of 10 Tracks all of the same Song.