I'm working on a V2 controller and had some questions. Given the inconsistencies of the V1 code, I was hoping we could maybe standardize the code design for our v2 controllers/views/etc (at least in Katello). I'm not sure if any of this applies to Foreman unless we want to standardize across both apps. Here are some of my questions:
- Does /systems/:id/subscriptions route to systems#subscriptions or subscriptions#index? We seem to have nested routes that differ on this in V2 (e.g. systems#subscriptions vs system_group#systems).
- Should we maybe turn on wrap_params instead of calling params.slice(…) and params.except(…) everywhere?
- When should we nest associations? I saw that we have like system_groups/:id/systems but that we were not allowing organizations/:id/system_groups. Where do we draw the line?
- It seems like the search code is duplicated in a lot of places in V2. Should we try to DRY this up?
I'm wondering if we should address these as they come up? Should we maybe try to include their resolutions in the V2 developer documentation?
Thanks.
David
> I'm working on a V2 controller and had some questions. Given the inconsistencies of the V1 code, I was hoping we could maybe standardize the code design for our v2 controllers/views/etc (at least in Katello). I'm not sure if any of this applies to Foreman unless we want to standardize across both apps. Here are some of my questions:
>
> 1. Does /systems/:id/subscriptions route to systems#subscriptions or subscriptions#index? We seem to have nested routes that differ on this in V2 (e.g. systems#subscriptions vs system_group#systems).
What do you mean route? I would assume that /systems/:id/subscriptions
is equivilant to /subscriptions?system_id=:id
> 2. Should we maybe turn on wrap_params instead of calling params.slice(…) and params.except(…) everywhere?
> 3. When should we nest associations? I saw that we have like system_groups/:id/systems but that we were not allowing organizations/:id/system_groups. Where do we draw the line?
I would assume we eventually do all nested…
– bk
···
On 11/19/2013 05:40 PM, David Davis wrote:
> From: "David Davis" <daviddavis@redhat.com>
> To: "foreman-dev" <foreman-dev@googlegroups.com>
> Sent: Wednesday, November 20, 2013 12:40:24 AM
> Subject: [foreman-dev] V2 API questions
>
> I'm working on a V2 controller and had some questions. Given the
> inconsistencies of the V1 code, I was hoping we could maybe standardize the
> code design for our v2 controllers/views/etc (at least in Katello). I'm not
> sure if any of this applies to Foreman unless we want to standardize across
> both apps. Here are some of my questions:
>
> 1. Does /systems/:id/subscriptions route to systems#subscriptions or
> subscriptions#index? We seem to have nested routes that differ on this in V2
> (e.g. systems#subscriptions vs system_group#systems).
Both are possible depending on how routes.rb is defined, but the RESTful way is /systems/:id/subscriptions => subscriptions#index with params['system_id']=:id. Note the #index action needs to do the filtering. It's not automatic.
> 2. Should we maybe turn on wrap_params instead of calling params.slice(…)
> and params.except(…) everywhere?
> 3. When should we nest associations? I saw that we have like
> system_groups/:id/systems but that we were not allowing
> organizations/:id/system_groups. Where do we draw the line?
> 4. It seems like the search code is duplicated in a lot of places in V2.
> Should we try to DRY this up?
Please give example. In foreman, you will see as an example
Puppetclass.search_for(*search_options)
where def search_options is defined in base_controller.rb
···
----- Original Message -----
I’m wondering if we should address these as they come up? Should we maybe try
to include their resolutions in the V2 developer documentation?
Thanks.
David
–
You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
> From: "Bryan Kearney" <bryan.kearney@gmail.com>
> To: foreman-dev@googlegroups.com
> Sent: Wednesday, November 20, 2013 2:30:56 AM
> Subject: Re: [foreman-dev] V2 API questions
>
> > I'm working on a V2 controller and had some questions. Given the
> > inconsistencies of the V1 code, I was hoping we could maybe standardize
> > the code design for our v2 controllers/views/etc (at least in Katello).
> > I'm not sure if any of this applies to Foreman unless we want to
> > standardize across both apps. Here are some of my questions:
> >
> > 1. Does /systems/:id/subscriptions route to systems#subscriptions or
> > subscriptions#index? We seem to have nested routes that differ on this in
> > V2 (e.g. systems#subscriptions vs system_group#systems).
>
> What do you mean route? I would assume that /systems/:id/subscriptions
> is equivilant to /subscriptions?system_id=:id
This is correct.
>
> > 2. Should we maybe turn on wrap_params instead of calling params.slice(…)
> > and params.except(…) everywhere?
I would add Foreman's config/initializers/wrap_parameters.rb to Katello's initializers
> > 3. When should we nest associations? I saw that we have like
> > system_groups/:id/systems but that we were not allowing
> > organizations/:id/system_groups. Where do we draw the line?
>
> I would assume we eventually do all nested…
Correct, it is the goal to add as many nested routes as possible.
···
----- Original Message -----
> On 11/19/2013 05:40 PM, David Davis wrote:
– bk
–
You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.