4 ms·
This seems like a great idea! I have a few thoughts that comes to mind, perhaps others can chip in: - How can this be used in tandem with strong_parameters; sh
by sandstrom 14y ago
This seems like a great idea! I have a few thoughts that comes to mind, perhaps others can chip in:
- How can this be used in tandem with strong_parameters; should ensuring the structure of params be a responsibility of the controller or the mutation (I'm leaning towards the former)? [1]
- How can validation duplication between models and mutations be avoided? In the example 'string :email, matches: EMAIL_REGEX' was used, but presumably one will still validate the email in the model. I'm guessing there are solutions to this, perhaps the existing model validation can somehow be used?
[1]: https://github.com/rails/strong_parameters https://github.com/rails/strong_parameters
- jbverschoor 14y agoYou could probably write something like: User.email.validation Similar to that query project.. Can't remember the name now :-)
- cypriss 14y agoWe're using this in Rails 2.3 without Strong Parameters. Mutations whitelist input just like strong parameters do. I don't really see why you would use both, although you certainly could. The duplicate of validations between models and mutations is interesting. Currently at UV, we have some duplication -- however, in other cases we're relying entirely on the validations of the Mutation. I do think it's possible to rely entirely on validation from mutations -- I need to get some more real-world experience with this to know how well it will work out :)