[Rails] Re: Rails 5.2 Custom Credentials — generally accepted way to segregate environments?

2019-06-10 Thread Eric Anderson
I've found the rails-env-credentials gem useful for this. Not sure how compatible it will be with the upcoming Rails 6 support but its been working great for my app. Eric On Sunday, June 9, 2019 at 9:40:05 PM UTC-4, Jason Fleetwood-Boldt

[Rails] Re: How do you generically call a scope on a model?

2019-03-18 Thread Eric Anderson
I don't have the answer to your question, but I wouldn't say `send` is inherently evil. It all depends on the source of the data. If your `scope` argument is some meta-programming (i.e. the value is defined by the programmer) then it can be safe to use. If it is user input then obviously you

[Rails] Re: PostgreSQL Array column + has_many association

2019-02-04 Thread Eric Anderson
I don't think this is supported out-of-the-box in Rails but I did see this extension a while back that appears to add what you are looking for: https://github.com/marshall-lee/has_array_of Haven't personally used it but looks promising. Eric On Wednesday, April 11, 2018 at 7:51:00 AM UTC-4,

[Rails] Re: Proper Coding Question

2018-10-04 Thread Eric Anderson
I agree with Rob that it is in the realm of taste and preference. I wouldn't have something like this in my view: users = User.where(active: true).join(:transactions).merge(Transaction.where('total > 1000')) form.collection_select users, :id, :name This would be putting model level

[Rails] Re: Proper Coding Question

2018-10-03 Thread Eric Anderson
There is an `collection_select` form builder that will do the `collect` for you. So: <%= f.collection_select :user, policy_scope(User), :id, :name %> If you are not using a form builder then `options_from_collection_for_select` is useful for the same purpose. If those helpers cannot be