[katello-devel] Refactoring - params unification

Petr Chalupa pchalupa at redhat.com
Tue Feb 26 10:59:44 UTC 2013



On 26.02.13 11:47, Ivan Necas wrote:
> What about dropping params[:id] completely and using always explicit names, such
> as params[:user_id], parmas[:organization_id] etc. This complicates the reusability
> of the code: for example using before filter in moar controllers.
>
> -- Ivan

I would love that but we would have to wait for newer version of Rails. 
AFAIK the param key :id is hard-coded in Rails 3.0 routes code.

>
> ----- Original Message -----
>> I would like to have some rules in place to be able to determine
>> exact
>> meaning of the value in params based on its key and controller name.
>> e.g.
>>
>>       UsersController#params[:id] == user.id # UsersController
>>       therefore
>> it has to be user's id
>>       UsersController#params[:user][:login] == user.login
>>       UsersController#params[:user_login] # I would not allow this
>>       UsersController#params[:organization_id] == organization.id # I
>> would make exception for ids, no need for nesting
>>       UsersController#params[:organization][:name] ==
>>       organization.name
>>
>> If we have these rules, params will became more predicable. Then We
>> can
>> also unify all the code for model finding (find_* methods in
>> controllers) and create objects to be responsible for it, see
>> [draft][1].
>>
>> We would have model-finding explicitly specified in methods instead
>> of
>> sometimes-unclear before filters.
>>
>> [1]:
>> https://github.com/pitr-ch/docs/blob/master/Katello/Proposals/Params%20unification/draft.rb
>>
>> Petr
>>
>> _______________________________________________
>> katello-devel mailing list
>> katello-devel at redhat.com
>> https://www.redhat.com/mailman/listinfo/katello-devel
>>
>
> _______________________________________________
> katello-devel mailing list
> katello-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/katello-devel
>




More information about the katello-devel mailing list