Re: [Rails-core] [Feature][ActiveRecord] `where.or` query method

2019-10-10 Thread Kevin Deisz
For more complex queries, so syntactic sugar can make this a little more palatable: Author.some.complex.scopes.then { |relation| relation.where(first_name: 'John').or(relation.where(last_name: 'Smith')) }.more.complex.scopes Even better is just extracting that to its own named scope, scope

Re: [Rails-core] Re: Interactive `rails new`

2018-08-04 Thread Kevin Deisz
You can also just use the .railsrc file from your home directory to specify those args every time. https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/USAGE On Sat, Aug 4, 2018 at 5:24 AM Xavier Noria wrote: > The application generator has about 25 options, I

Re: [Rails-core] [Feature request][ActionPack::ActionDispatch::Routing] Add parameter for resources to alias "only: []" in routes.rb

2018-01-18 Thread Kevin Deisz
action: :bar, as: :bar > end > end >Prefix Verb URI Pattern Controller#Action > users_unsubscribe GET /users/unsubscribe(.:format) users#unsubscribe > users_foo GET /users/:id/foo(.:format) users#foo > users_bar POST /users/:id/bar(.:format) u

Re: [Rails-core] Re: [Feature request][ActionPack::ActionDispatch::Routing] Add parameter for resources to alias "only: []" in routes.rb

2018-01-18 Thread Kevin Deisz
You can achieve this functionality by throwing this into the top of your routes drawing block: ``` def subresources(name, ) resources(name, only: [], ) end ``` since that block is getting instance_eval'd anyway, this will just put that method onto the routes object. Then you can: ```

Re: [Rails-core] [Feature request] [ActiveRecord] Automatically create scopes for models boolean attributes

2018-01-04 Thread Kevin Deisz
IIRC, this was actually a thing in Rails 2 and it got taken out. I agree with you about the convention over configuration idea, but when you only need the one line of code to get it back, and it relieves a maintenance burden and makes things faster, I'd have to side with it not being in core.

Re: [Rails-core] Allow to use rails style on queries with specific order

2017-10-19 Thread Kevin Deisz
Are you using MySQL? It has a field function that solves this https://www.w3schools.com/sql/func_mysql_field.asp You could probably do the same thing with substring index with other DBMSs. On Thu, Oct 19, 2017 at 1:30 PM Pablo Margreff wrote: > I have a situation which I

Re: [Rails-core] Re: [Feature request] has_many option to generate additionnal has_many for each given scope.

2017-04-10 Thread Kevin Deisz
Probably a better first step would be to move this into a gem and then if it garners wide enough adaption making the case then. On Mon, Apr 10, 2017 at 11:16 AM, Joshua Flanagan wrote: > The "before" version really doesn't seem that painful. Compared with the > cost to

Re: [Rails-core] ActiveRecord per user/tenant connection pool

2015-12-12 Thread Kevin Deisz
We've done it using MySQL views. You construct all tenant-dependent views with a tenant_id column and set the formula to check against a session variable. We put insert triggers to set the tenant_id initially and an update trigger to throw an error if someone tried to change it (they can't through

Re: [Rails-core] link_to_if/link_to_unless inconsistencies

2015-11-05 Thread Kevin Deisz
, 2015 at 3:54 PM, Rafael Mendonça França < rafaelmfra...@gmail.com> wrote: > It is the way they work. See the documentation. The block is used only > when the condition is not met. > > On Thu, Nov 5, 2015 at 1:26 PM Kevin Deisz <kevin.de...@gmail.com> wrote: > &g

Re: [Rails-core] link_to_if/link_to_unless inconsistencies

2015-11-05 Thread Kevin Deisz
wrote: > If that is possible without breaking backward compatibility go ahead, but > I can't think in a way to make it backward compatible. > > On Thu, Nov 5, 2015 at 2:00 PM Kevin Deisz <kevin.de...@gmail.com> wrote: > >> I get that that's the way that it works, my point was tha

[Rails-core] link_to_if/link_to_unless inconsistencies

2015-11-05 Thread Kevin Deisz
Hi there, Seems like in the positive condition, link_to_if and link_to_unless are inconsistent. When I send a block to link_to (or for that matter anything else that calls content_tag) the block is used to determine the content in the case that "name" is not provided. It gets around this by

[Rails-core] Errors inside custom setters

2015-09-10 Thread Kevin Deisz
Hi there, I've got a custom setter in a model that add errors in the case that the given value is invalid. In the case that it is invalid, I've had a lot of difficulty getting the model to validate false. It looks like in active model we call errors.clear before run_validations!. This makes sense

Re: [Rails-core] Errors inside custom setters

2015-09-10 Thread Kevin Deisz
yway, if you really need to do that I'd recommend doing as you said, > detect on the setter but only add the error upon validation. > > On Thu, Sep 10, 2015 at 4:13 PM, Kevin Deisz <kevin.de...@gmail.com> > wrote: > >> Hi there, >> >> I've got a custom sette

Re: [Rails-core] Errors inside custom setters

2015-09-10 Thread Kevin Deisz
ou're handing it on your own? It seems a lot to handle. > > Anyway, those are my thoughts, maybe someone else has a new opinion on > this :). > > Hope that helps. > > On Thu, Sep 10, 2015 at 4:22 PM, Kevin Deisz <kevin.de...@gmail.com> > wrote: > >> Hi Carlos,

Re: [Rails-core] Always set id from database when creating new record

2015-08-21 Thread Kevin Deisz
Wouldn't doing so disallow you from manually setting the ID? I know it's a weird case but we do this in our product in a table with string IDs. On Fri, Aug 21, 2015 at 5:07 AM, masa331 do...@uol.cz wrote: Hi guys, this is code from ActiveRecord::Persistance: def

Re: [Rails-core] Feature proposal: Use find_each/find_in_batches with pluck

2015-08-16 Thread Kevin Deisz
By the way, with the new in_batches API you can do this. a la User.some_scopes.in_batches.each do |users| users.pluck(:id) end On Wed, Jul 22, 2015 at 6:44 AM, Fernando Tapia Rico fertap...@gmail.com wrote: +1 On Friday, June 19, 2015 at 2:35:30 PM UTC+2, Paco Guzmán wrote: Yes, that

[Rails-core] Rails API

2015-07-30 Thread Kevin Deisz
With edge rails, is there a way to have API controllers and normal controllers living in the same app? The only way I've found to do that is to mount the API as a separate rack app, which I'd really rather not do. -- You received this message because you are subscribed to the Google Groups

[Rails-core] rake stats

2015-07-22 Thread Kevin Deisz
Is there a reason that rake tasks are not part of rake stats? We have a lot of different rake tasks and I'd like to have them show up in our statistics so we can monitor as they grow/change. I'd be happy to submit a PR for this if it would be accepted. -- *Kevin D. Deisz* *TrialNetworks* - part

Re: [Rails-core] RFC: Remove support for passing argument to force association reload

2015-07-14 Thread Kevin Deisz
Can't you chain like record.associations(reload: true).where - if you do reload I think we'd lose that On Tuesday, July 14, 2015, Prem Sichanugrist sikand...@gmail.com wrote: I already asked a question about refactoring `record.associations(true)` - `record.associations(reload: true)` here:

Re: [Rails-core] Re: Schema.rb table and column order

2015-05-19 Thread Kevin Deisz
With all of these threads about schema.rb format - would it just be easier to allow you to specify your own formatter? Have something that responds to format_for(table, columns) or something to that effect? The issue here is that everyone is going to want something different from that file. On

[Rails-core] schema.rb

2015-05-18 Thread Kevin Deisz
ActiveRecord::SchemaDumper currently dumps out create_tables for every view in the database as well (this is mysql2 I'm talking about). This happens to be a lot of views for us, and we end up deleting them and then manually adding them back in whenever we need to db:schema:load. Is there a