首先发布在这里!我正在尝试扩展设计以使用可恢复选项,以便用户可以向其发送带有密码重置链接的电子邮件。
我在user.rb模型中设置了可恢复选项:
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable, :omniauth_providers => [:facebook]
我已将以下内容添加到views / devise / sessions / new.html的登录表单中:
<div class="form-group">
<%= f.label :password_confirmation, class: "sr-only" %>
<%= f.password_field :password_confirmation, placeholder: "Confirm Password", autocomplete: "off", class: "form-control" %>
</div>
然而,当我点击该链接时,它会将我带到http://localhost:3000/users/password/new,页面为空白(它会拉入页眉和页脚,但没有内容),我建议我已经拥有该页面,但可以&#39 ; t在我的代码库中找到它,这是正确的吗?我假设如果我没有那个页面,它会抛出404错误吗?
所以我想要了解的事情是:
a)如何创建新视图并在该URL上显示它 b)我需要添加电子邮件表单和提交按钮,但这段代码是什么样的?
任何帮助都会非常感激,我知道这可能是非常基本的东西,我似乎无法绕过它!
Rails版本4.2.0
Ruby版本2.0.0
提前致谢。
丹
答案 0 :(得分:0)
为了拥有和修改设计视图,您应该生成它们。因此,在projet目录中运行此命令:
rails generate devise:views model_name
这将在“prject_path / app / views / devise”中生成视图,该视图将用于所有设计模型。如果您有多个设计模型,则应使用:
class TestItem
{
public:
typedef bool (*TestFuncDef)(const state_type& state_to_test, std::shared_ptr<result_type>& result_ptr);
TestItem(TestFuncDef test_fn_parm)
{
test_fn = test_fn_parm;
already_invoked = false;
}
bool Invoke(const state_type& state_to_test, std::shared_ptr<result_type>& result_ptr)
{
already_invoked = true;
return test_fn(state_to_test, result_ptr);
}
bool AlreadyInvoked() const {return already_invoked; }
private:
TestFuncDef test_fn;
bool already_invoked;
};
std::shared_ptr<result_type> RunTest(std::list<TestItem>& test_item_list, state_type& state_to_test)
{
for(;;) {
bool made_a_test = false;
for (TestItem& item : test_item_list) {
std::shared_ptr<result_type> result_ptr;
if (!item.AlreadyInvoked()) {
made_a_test = true;
if (item.Invoke(state_to_test, result_ptr)) {
return result_ptr;
}
else
continue;
}
}
if (!made_a_test)
throw appropriate_exception("No conditions were matched");
}
}
这将生成“prject_path / app / views / model_name”,这将仅用于一个模型。
重置密码视图是“prject_path / app / views / devise / passwords / edit.html.erb”并且它需要功能,但是为了发送邮件,您应该设置您的应用程序。我建议你:Getting Devise 1.3.4 to send emails with Gmail in development