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
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
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
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:
```
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.
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
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
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
, 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
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
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
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
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
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,
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
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
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
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
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:
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
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
21 matches
Mail list logo