Chris Oliver

Joined

291,200 Experience
86 Lessons Completed
299 Questions Solved

Activity

Posted in Populate dropdowns based on selection with Stimulus JS

You need to have your callback using a fat arrow => instead so it keeps the scope.

      success: (data) => {
        this.message()
        this.doThingWithData(data)
      }

That will retain the scope so that this refers to the Stimulus controller. That will fix your method call error.

Posted in running new app showing error.

I believe that's the current solution. The next version of Rails will fix this, but we just have to wait and use your solution until then. 👍

Posted in How can i create a contact form in rails.

You might try this gem called mail_form: https://github.com/plataformatec/mail_form

Posted in Why have the three dots syntax?

The triple dots are called the object spread operator. Basically it allows you to expand variables in useful ways to simplify the code you're writing. Here's a couple articles about it:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
https://medium.com/@oprearocks/what-do-the-three-dots-mean-in-javascript-bc5749439c9a

Posted in Creating an application Multi Language

Hey Kelvin,

I'm not too familiar with it, but you might try this gem: https://github.com/globalize/globalize

It can help you on the ActiveRecord model side to handle languages using a translations table it looks like.

Posted in Stripe Subscriptions: Duplicate Customers

Thomas, the Stripe series is new a separate course from GoRails: https://courses.gorails.com/payments-with-rails-master-class

It covers the latest Stripe with a shopping cart example for one-time payments, Stripe Billing subscriptions. Soon it will have Braintree + PayPal examples in the course as well.

Posted in Spree - What is the secret key of spree? Ask Question

You would probably need a multitenant plugin for Spree to do that.

Looks like there are a few gems for this:
https://github.com/spree-contrib/spree-multi-domain
https://github.com/spree-contrib/spree_shared

I haven't used Spree in years, so hopefully that helps point you in the right direction!

One thing to note: you would use Puma OR Passenger, but not both. Apache can proxy requests over to Puma, or you can have it send requests to Passenger. It's definitely easier to use Passenger because you don't have to have another process running.

Rails comes with Puma by default now to support web sockets in development, and you could also run Puma in production, but you have to run it as a separate background process with SystemD.

If you're using Passenger, you don't need to do that and you can just define the Server in Apache to have it load it.


When you say you have no problem connecting when using Puma, do you mean by running "rails console"?

Also can you share the full stacktrace for your error?

Hey William!

Sounds like just a database connection issue. Puma may start up just fine because it doesn't care about the database.

You can more easily test the configuration by using the Rails console in production and seeing if you can query the database.

RAILS_ENV=production bundle exec rails c
> User.first

Chances are you'll just need to adjust your database.yml or if you're using ENV variables for production.

I don't know anything about TinyTDS, so if you can connect to the DB but it dies at some point, you might want to ask on their Github issues.

Posted in Setup Windows 10 Discussion

I don't use RubyMine, but according to this, you might need to point to the ruby version inside the .rbenv folder instead of the shim. That way rubymine can find the gems directory correctly.

You can read the post here: https://df.tips/t/topic/326/3

Posted in How to debounce ActiveJobs?

Possibly this with a supported backend queue? https://github.com/y-yagi/activejob-cancel

I think when you enqueue a job it gives you back an ID. You could probably save that ID to the model that's being processed and look for a match when the job starts to only allow that Job ID to do the processing.

Posted in application.html.erb Help

Anytime! Keep posting if you have more questions. 🙌

Posted in application.html.erb Help

Strange, maybe it got deleted somehow?

If you generate a new Rails app, you can just copy the file from that one and put it into your existing one.

Posted in application.html.erb Help

That should be in app/views/layouts/application.html.erb

You shouldn't keep the client id and secret in your codebase unless it's encrypted. That way if you shared your repo with someone, they wouldn't be able to steal access to all the user's social accounts.

If you're using Rails 5.2, you can put them in the encrypted credentials file by running rails credentials:edit.

Posted in Contribute to a gem

Yeah, it can get a little weird sometimes. You might suggest a good feature, but they might not use it or know how it works which makes for a reason they might not want to accept a feature. Hopefully you'd be able to help out and maintain it, that's very helpful.

It's really common for them to come back with suggestions to improve the code. Especially because they have to maintain it, they want to make sure it's similar style to their existing code so it's easy to understand. It's usually a back-and-forth discussion about how to implement things which is great.

One of the most helpful things you can do to get involved is to help out on all the other issues reviewing other PRs or issues or documentation. Then the maintainer gets to work with you a bit and the rapport helps when proposing features.

An example of a PR discussion of new features is this one on Stimulus. It came from the original developers, but they want to see what the community thinks and if it will be helpful or not. https://github.com/stimulusjs/stimulus/pull/202

Devise + Omniauth is typically the easiest route. Devise will handle the regular email logins and social auth via Omniauth.

I've done several videos on this.

https://gorails.com/search?utf8=%E2%9C%93&q=omniauth

Posted in Contribute to a gem

These are great questions. Really, you should open an issue before you do any work because the maintainer of the gem is the one who will have to support your code.

Ask them if they're interested in adding X feature and if they'd be willing to accept your pull request. You can also ask them about how you should approach it, how to write tests, and how to handle those imperfect situations. They'll usually be more than happy to help you through it.

Posted in Routing for Admin area not working

You can just pass in an array of items to tell Rails the correct scoping when it generates the route in the form.

<%= form_with model: [:admin, @article], method: :post do |f| %>

The url option works as well, like eelcoj mentioned, but you'll more commonly see the model being used for forms that are for models. The url option is normally used for custom forms that aren't model backed.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.