【发布时间】:2012-03-31 06:38:58
【问题描述】:
我在 Heroku 不玩球并给我这个错误时遇到问题
ActionController::RoutingError (No route matches [POST] "/auth/identity/register"):
我在开发中有以下工作。
模型/用户.rb
class User < OmniAuth::Identity::Models::ActiveRecord
has_many :services
控制器/users_controller.rb
def new
@user = env['omniauth.identity'] || User.new
end
用户/new.html.erb
<%= simple_form_for @user, url: "/auth/identity/register" do |f| %><fieldset>
<legend><%= controller.action_name.capitalize %> User</legend>
<%= f.input :name, input_html: { name: "name" } %>
<%= f.input :email, input_html: { name: "email" } %>
<%= f.input :password, input_html: { name: "password" } %>
<%= f.input :password_confirmation, input_html: { name: "password_confirmation" } %>
<div class="form-actions">
<%= f.button :submit %>
<%= link_to 'Cancel', users_path, :class => 'btn' %>
</div></fieldset><% end %>
routes.rb
match "/auth/:service/callback" => 'services#create'
match "/auth/failure" => 'services#failure'
resources :users
这一切都在我的机器上完美运行,但 Heroku 不喜欢它。 environment/development.rb 和 production.rb 是使用“rails new...”创建的默认值,并添加了以下内容:-
Rails.application.config.middleware.use OmniAuth::Builder do
require 'openid/store/filesystem'
provider :identity, fields: [:name, :email],
model: User,
on_failed_registration: lambda { |env|
UsersController.action(:new).call(env)
}
# generic openid
provider :open_id, :store => OpenID::Store::Filesystem.new('./tmp'), :name => 'openid'end
希望这一切都有意义,并且有人给出了答案。非常感谢任何和所有帮助。
问候
【问题讨论】:
-
有趣的是,如果我使用来自 Slainer68 的 omniauth-identity "here"link 的分叉版本。我在本地遇到与 Heroku 相同的错误“没有路由匹配 [POST]”/auth/identity/register“):”。所以我想强制使用在本地工作的正确版本“gem omniauth-identity,'1.0.0'”,这样 Heroku 就不会加载不同的东西。但是很可惜,这个版本在本地仍然可以正常工作,并且在 Heroku 上会失败。
标签: heroku omniauth simple-form