customization

How to define custom Failure for devise in case of two different models User and active admin?

随声附和 提交于 2020-08-22 05:38:36
问题 I have two models User and ActiveAdmin on which I want to apply my devise integrations. I have my custom_failure.rb as follows class CustomFailure < Devise::FailureApp def redirect_url login_path end # def redirect_url # root_path # end def respond if http_auth? http_auth else redirect end end end Which seems to be working great. Also, can define in my application controller like : def after_sign_in_path_for(resource) # case resource if resource.is_a?(Admin) admin_dashboard_path else root

Embed custom filter definition into jinja2 template?

随声附和 提交于 2020-08-06 12:47:32
问题 I'm writing some Jinja2 templates that I'd like to be able to reuse as painlessly as possible in tangentially related projects. I have a set of custom convenience filters that I'd like the templates to "carry around" with them. Is there a Jinja2 syntax for embedding filter definitions into a template itself? Or a mechanism for embedding any kind of pure Python function into a Jinja2 template that can act on variables passed into the template? I used to use mako, and there it was trivial to do

How to create html5 custom validation?

强颜欢笑 提交于 2020-07-09 13:45:32
问题 I am using html 5 form validation for validate my form before submit, if is valid, submit, but I need validate my User Register form, so it need validate if Password Confirm value is equal camp Password, below is my form example: <form> <label>Login:</label> <input type="text" name="login" id="login"/><br/> <label>Password:</label> <input type="password" name="pass" id="pass"/><br/> <label>Password Confirm:</label> <input type="password" name="pass_conf" id="pass_conf"/><br/> <input type=