usecasing icon indicating copy to clipboard operation
usecasing copied to clipboard

Loses the ability to use rails strong params

Open alexandru-calinoiu opened this issue 10 years ago • 8 comments

With the context wrapping the params, require does not work anymore, how about adding the require in the Context.

Does it sound like a good idea? I can put a PR if you want.

alexandru-calinoiu avatar Jul 15 '15 14:07 alexandru-calinoiu

@joaquimadraz could you see that ?

tdantas avatar Feb 09 '16 22:02 tdantas

@alexandru-calinoiu still an issue to you ? let me know !

cheers

tdantas avatar Feb 18 '16 20:02 tdantas

@tdantas Sorry for the delay. I haven't check this issue. Next couple of weeks will be busy for me. Can you check that?

joaquimadraz avatar Feb 18 '16 20:02 joaquimadraz

take your time @joaquimadraz.

tdantas avatar Feb 18 '16 20:02 tdantas

Hey @alexandru-calinoiu! Sorry, I need some context to help you on this one. Isn't require used to whitelist params sent to a server? How is that related with the usecasing context? Can you give me a use case using require on Context?

Thanks and sorry for the late response!

joaquimadraz avatar Mar 27 '16 16:03 joaquimadraz

The idea is I want to implement some sort of a contract for my context.

So if the before method for a use case I ca do:

def before
 context.requires(:current_user)
end

Does this make sens?

alexandru-calinoiu avatar Mar 31 '16 07:03 alexandru-calinoiu

Most of the times, I validate the context and if something is missing I just call stop!.

If something like this should exist, maybe as class method?

class FindInvoice < UseCase::Base

  required_context :current_user, :invoice_id

  def perform
    ...
  end

end

@tdantas what do you think?

joaquimadraz avatar Apr 01 '16 15:04 joaquimadraz

:+1: looks great !

another heads up. testing is failing on 1.9.3 ruby version, can you see that ?

cheers

tdantas avatar Apr 01 '16 18:04 tdantas