Итак, у меня возникла интересная проблема. Я пытаюсь переопределить и перенаправить запрос sign_up и sign_in на соответствующие страницы профиля, но сталкиваюсь с ошибкой. Профили и URL-адрес работают при доступе к ним с помощью консоли, link_to или путем ввода. По какой-то причине метод devise не будет направляться к нему. Я не уверен, почему. В любом случае, голосуйте за всех, кто вносит свой вклад или решает. Спасибо!
Маршруты:
root :to => 'pages#index'
get "pages/index"
devise_for :users, :path => 'accounts', :controllers => { :registrations => "registrations" }
get 'users/:id/profile' => 'profiles#show', :as => 'current_profile'
get 'users/:id/profile/edit' => 'profiles#edit', :as => 'edit_current_profile'
put 'users/:id/profile' => 'profiles#update'
resources :users do
resources :profiles
end
Контроллер регистрации:
class RegistrationsController < Devise::RegistrationsController
protected
def after_sign_up_path_for(resource)
edit_current_profile_path(resource)
end
def after_sign_in_path_for(resource)
current_profile_path(resource)
end
end
Контроллер профиля
def show
@user = current_user
@profile = @user.profile
respond_to do |format|
format.html
end
end
Сообщение об ошибке:
Routing Error
No route matches {:controller=>"profiles", :action=>"show"}
Try running rake routes for more information on available routes.
Просмотр: edit.html.erb
<%= form_for([@profile.user, @profile]) do |f| %>
<% if @profile.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@profile.errors.count, "error") %> prohibited this profile from being saved:</h2>
<ul>
<% @profile.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :real_name %><br />
<%= f.text_field :real_name %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>