Guest User

Untitled

a guest
May 25th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Imagine i have
  2.  
  3. class Articles < Application
  4.  
  5. # params will have :article key here!
  6. def create(attributes)
  7. ...
  8. end
  9. end
  10.  
  11.  
  12.  
  13. # merb-action-args code
  14.  
  15. def _call_action(action)
  16. arguments, defaults = self.class.action_argument_list[action]
  17. args = arguments.map do |arg, default|
  18. arg = arg
  19.  
  20. # HERE the parameter name must be *right* so that everything works !?!
  21. # arg will be attributes here, but params doesn't contain it, it contains :article
  22.  
  23. p = params.key?(arg.to_sym)
  24. raise BadRequest unless p || (defaults && defaults.include?(arg))
  25. p ? params[arg.to_sym] : default
  26. end
  27. __send__(action, *args)
  28. end
Add Comment
Please, Sign In to add comment