2017-10-27 3 views
0

RAILS 여기 Newbie! 나는 모든 가능한 도움을 시도해 왔으며, 튜토리얼은 Devise 컨트롤러를 오버라이드하여 로그인/가입을 모드로 작성하는 것을 기본으로합니다 (기본적으로 AirBnB에서 가능한 한 가까이에 위치하고자합니다). '등록':Devise 가입보기를 모달로 설정

Rails.application.routes.draw do 
devise_for :users, 
    controllers: { omniauth_callbacks: 'users/omniauth_callbacks', registrations: ‘registrations’ } 

root to: 'pages#home' 
end 
- : registrations_controller.rb JS의 사용을 고안 수 있도록 :> 등록

class Users::RegistrationsController < Devise::RegistrationsController 
respond_to :js 
end 

가 함께 route.rb 업데이트를

나는 새로운 컨트롤러를 만들었습니다

그리고 마지막으로 유증/등록에서 파일

<div id=”modal” class=”modal fade”></div> 

<div class="modal-dialog modal-sm"> 
<div class="modal-content"> 
    <div class="modal-header"> 
    <button class="close" data-dismiss="modal">x</button> 
    <h2 class="dark">Log in</h2> 
</div> 
<div class="modal-body"> 
    <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> 
    <%= f.error_notification %> 

    <div class="form-inputs"> 
     <%= f.input :name, required: true, autofocus: true %> 
     <%= f.input :email, required: true, autofocus: true %> 
     <%= f.select :university, options_for_select(%w[Mcgill Concordia Others]), {:include_blank => "Select your university" } %> 
     <%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %> 
     <%= f.input :password_confirmation, required: true %> 
    </div> 

    <div class="form-actions"> 
     <%= f.button :submit, "Sign up" %> 
    </div> 
    <% end %> 

    <%= render "devise/shared/links" %> 
    </div> 
</div> 
</div> 

및 생성 new.js.er _new.html.erb 사용 일부이든 new.html.erb을 렌더링하는 B :

$(‘#modal’).html(‘<%= j render(“new”) %>’); 
$(‘#modal’).modal(); 

나는 그것이 나에게 오류를 제공하는 서버 시작하려고 :

undefined local variable or method `‘registrations’' 

사람이 이유를 설명 할 수 있습니까? 감사!

+0

왜이 아포스트로피가이 줄의 등록에서 다르게 보이나요? '컨트롤러 : {omniauth_callbacks : '사용자/omniauth_callbacks', 등록 : '등록'}' –

답변

0

나는 항상 PC가 정확하다고 말하고 싶습니다. ;)

모달보기 컨트롤러에서 "사용자"는 "사용자 컨트롤러"를 라우팅하기위한 컨트롤러가 필요하며이 컨트롤러에는 메서드가 필요합니다. def index end이 메서드는 views/user/index.html.erb보기로 연결됩니다. html 컨텐트를 Ajax를 통해로드하고 싶거나 여기 에서처럼 간단하게 뷰를 렌더링 할 수있다. render form| to ./_form.html.erb

당신의 경우에는 메소드를 검색한다. 브래드 도끼로 ‘registrations’ (: 오류 방법 검색을 통해 렌더링 싶어 할 때,

0

그것은뿐만 아니라 비 고전 등록에 아포스트로피 수 있음))

을 나는 그냥 물어 경우, 이해 바랍니다 주의).

당신은 (가있는 경우) registrations: 'users/registrations' 같은 키 - 값 쌍은 controllers/users/registrations_controller.rb사용자 : RegistrationsController을 위해 특별히 검색 ActionDispatch 라우터에게 지정 시도 할 수 있습니다.

그런 다음 rake routes을 사용하여 라우팅 정확성을 확인할 수 있습니다.

또한 예외가 발생하는 정확한 파일과 코드 줄을 찾을 수있는 오류 로그 (아래 오류 메시지 아래)의 버그를 추적하는 것이 유용합니다.