eelcoj

Joined

8,350 Experience
0 Lessons Completed
10 Questions Solved

Activity

To follow-up on Chris' last reply, in the past I've done:

self.slug = SecureRandom.hex(2).

on a model create method and then added that as part of the slug.


SecureRandom (apidock)

Posted in Simple_form Chrome browser bug

Did you forgot to add the actual Css?

Any link to an example would be helpful too.

Posted in Simple_form Chrome browser bug

Without any link or code it's hard to tell what's going wrong here.

Posted in Simple_form Chrome browser bug

By "overlapping" you mean the bordered-box doesn't include all list items?
Bit hard to understand what exactly you mean here :) But in any case it looks like a Css issue to me.

Yes, the edit is the way I went for. Per invoice there's just one currency, so no need for conversion there.
I've been upping my regexp skills since this feature.
Really now just need to whip up something to easily test against various cases, since I do it manually now 😅

Any regexp experts here? I have the following situation:

  • get an invoice
  • scan it for prices and save the highest number
  • success 🍾

I do this with a .scan(/…/). Pretty fast in Ruby. ✨

Format of pricing, and thus why the regexp gets tricky, can be really all over the place, some examples:

€100,-
€ 59,95
$ 100
$ 10.00
29 €
49,95 €
50 $

And any combination of above, including different type of spaces between currency and number :)

Current regexp looks like this, but that doesn't take into account the currency symbol after the price: /([€$]{1}[ \s]?)(\d{1,6}([,.]\d{1,2})?)/.

I am starting to think I need to think outside of using just regexp and need some ruby magic here, but hope any of you smart folks can help with that too.

Edit: just typing this post, I got the idea of separating the two. Scan for currency symbol first and then check for highest price. 💡

The default/convention here would be an url like: localhost:3000/sales.json
Any show action would, as a default, be like: localhost:3000/sales/1.json

Posted in How to add ssl to the CDN of AWS

If I'm correct you can a get ssl for cloudfront here. But it comes at a hefty price tag of $600.

The other option is to simply use the cloudfront url for this which by default goes over https.

Sorry? Switch controller? As in an action? To another action? And then submit the button?
Could you be a bit more clear, so we can help? :)

Posted in IFTT

So you're basically looking on how to setup an API, right? There were some GoRails casts added just recently. on that topic.

Posted in how do i link a comment to a specific post...

Really hard to read the code this way. Could you try to clean it up? Views can removed.
Also: check the log, check the error you have uninitialized constant Squeals and on which line and file this is. That part of the code might be worth to post here.

Posted in how do i link a comment to a specific post...

Not 100% sure what you're asking, but you want to add comments to a post? Not sure what you have apart from the scaffolded Controllers.

Post.rb
has_many :comments

Comment.rb
belongs_to :post

Be sure your comment model has post_id. From there you can try in in the rails console rails console, like so: Post.first.comments.create(body: 'My first comment to the first Post').

For more in depth, check this episode as well:
https://gorails.com/episodes/comments-with-polymorphic-associations?autoplay=1

Posted in Track user's usage per month

Thanks for the thorough answer, Chris.

I didn't explain it all too well. With 1. I meant simply *_counter columns on the User without any extra stuff going on.

I feel mostly for the extra "Counter" model, since it logs User's history + easier to look in the query beforehand.

Posted in How can I subscribe a user when creating a new project?

To "hide" projects, you can set something like this in your controller (most likely in your set_model method):

def set_params
  current_user.subscriptions.find(params[:id])
end

Posted in Track user's usage per month

So this is more an architecture question.

Lot's of SaaS's have this in place: a monthly cap of sorts of their service. So every [time period] a user can upload X files, connect with Y other users, etc.

Practically, I can think of three ways to go about this:

  1. before Model.create() check .count on assiociated model and accept or error
  2. add *_counter columns to the user's model and reset when new [time period] begins
  3. create a Counter model with keeps track of the usage per month

  4. is cimply a no-go.

  5. would work better already

  6. this would be the most sophisticated (there's a history for every user)

So how would you go about this? Anything obvious I am missing. A guide/read you can recommend?

Posted in SimpleMDE & RedCarpet

If I remember correct this is by design. Text "should" be wrapped by <p />'s.

Used it some time ago, so unsure if this behavior can be changed now.

Yes, you can simply do rails db:rollback or (rake db:rollback if rails < 5) to rollback the latest migration. And make changes to the migration as you like.

But note that if you already (git) pushed the faulty migration to a shared repository or deployed, you should make an additional migration.

Posted in Edit Data on same page

Only one way to find out :)

Posted in Edit Data on same page

Easiest, and if you're okay with using jQuery, is something like https://github.com/aaronchi/best_in_place

Not sure what you're usage is, but unless you're doing lots of (heavy) backgrounding I would stick with sucker_punch. Sidekiq adds quite a lot of extras which I am not sure is worth the time.

Now if you just want to learn how to do it, I am happy to give some pointers though :)


Edit: Ah, lots of valuable stuff already . 👍

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.