0
내 논리가 맞지만이 작업을 수행하고 있는지 확실하지 않습니다. 수동으로 고객을 추가 할 수있는 관리자가 있으며 고객이 등록 할 수있는 프론트 엔드가 있습니다.Rails 가입 방법 오류가 발생했습니다.
customers_controller.rb
class CustomersController < Admin::AdminController
def new
@customer = Customer.new
@customer.build_user
end
def create
@customer = Customer.new(params[:customer])
...
end
...
end
fronted_controller.rb
class FrontendController < ApplicationController
def show_signup
@customer = Customer.new
@customer.build_user
render "signup"
end
def signup
@customer = Customer.new(params[:customer])
...
end
end
routes.rb
match "signup" => "frontend#show_signup", :via => :get
match "signup" => "frontend#signup", :via => :post
프론트 엔드
<%= form_for @customer, :url => url_for(:controller => 'frontend', :action => 'signup'), :html => { :class => 'form-horizontal' } do |f| %>
<%= f.label :name, :class => 'control-label' %>
<%= f.text_field :name, :class => 'text_field' %>
이후 보여주는/signup.html.erb/가입 URL 그것은 나에게 문제가 오류
NoMethodError in Frontend#show_signup undefined method `name' for #<Customer id: nil ...
을 던져? 나는 관리자가 아닌 다른 컨트롤러에서 고객 모델에 액세스 할 수 있다고 생각합니다.
모델 : 고객은 관리자 섹션에서 작성하는 것이 좋습니다. user.rb
belongs_to :customer, :dependent => :destroy
...
customer.rb
has_one :user
...
당신에게 감사