NoMethodError
こんにちはprop_manager_controller.rb で 取得しているため、このエラーを解決できますか
PropManagerController#new の NoMethodError
undefined method `prop_manager?' for #<User:0x471f690>
コントローラー
class PropManagerController < ApplicationController
before_filter :login_required, :except => [:new, :create]
load_and_authorize_resource
# GET /prop_manager
# GET /prop_manager.json
def index
@prop_managers= PropManager.order('id:desc').page(params[:page])
respond_to do |format|
format.html #index.html.erb
format.json {render json: @prop_managers}
end
end
# GET /prop_manager
# GET /prop_manager.json
def show
@prop_managers= PropManager.order('id:desc').page(params[:page])
respond_to do |format|
format.html #show.html.erb
format.json {render json:@prop_managers}
end
end
# GET /prop_manager
#GET /prop_manager.json
def new
@prop_managers= PropManager.new
respond_to do |format|
format.html #new.html.erb
format.json {render json:@prop_managers}
end
end
# GET /prop_manager/1/edit
def edit
@prop_manager = PropManager.find(params[:id])
end
# POST /prop_managers
# POST /prop_managers.json
def create
@prop_manager = PropManager.new(params[:prop_manager])
respond_to do |format|
if @prop_manager.save
#UserMailer.delay.homeowner_welcome_email(@home_owner, params[:home_owner][:password])
UserMailer.propmanager_welcome_email(@prop_manager, params[:prop_manager][:password]).deliver
format.html { redirect_to prop_manager_path(@prop_manager), notice: 'PropManager was successfully created.' }
format.json { render json: @prop_manager, status: :created, location: @prop_manager }
else
@prop_manager.errors[:base] << @exception_message
format.html { render "new" }
format.json { render json: @prop_manager.errors, status: :unprocessable_entity }
end
end
end
# PUT /prop_manager/1
# PUT /prop_manager/1.json
def update
@prop_manager = PropManager.find(params[:id])
@prop_manager.card_validity = nil
begin
customer = Stripe::Customer.retrieve(@prop_manager.stripe_customer_id)
customer.email = params[:prop_manager][:email]
customer.card = { :number => params[:prop_manager][:credit_card_number],
:exp_month => params[:prop_manager][:credit_card_expiry_month],
:exp_year => params[:prop_manager][:credit_card_expiry_year],
:cvc => params[:prop_manager][:credit_card_cvc_code],
:name => params[:prop_manager][:credit_card_holder_name] }
customer.save
@prop_manager.card_validity = true
rescue => exception
@exception_message = exception.message
end
respond_to do |format|
if @prop_manager.update_attributes(params[:prop_manager])
format.html { redirect_to home_owner_path(@prop_manager), notice: 'PropManager account details updated successfully.' }
format.json { head :ok }
else
@prop_manager.errors[:base] << @exception_message
format.html { render action: "edit" }
format.json { render json: @prop_manager.errors, status: :unprocessable_entity }
end
end
end
# DELETE /home_owners/1
# DELETE /home_owners/1.json
def destroy
@prop_manager = PropManager.find(params[:id])
begin
customer = Stripe::Customer.retrieve(@prop_manager.stripe_customer_id)
customer.delete
rescue => exception
# Do nothing - there is no customer record in the stripe account
end
@prop_manager.destroy
respond_to do |format|
format.html { redirect_to prop_managers_url }
format.json { head :ok }
end
end
end
ルート
GEMS::Application.routes.draw do
resources :customer_feedbacks
resources :general_repairs_prices
resources :steam_cleaning_prices
resources :window_cleaning_prices
resources :roof_cleaning_prices
resources :gutter_cleaning_prices
resources :residential_jobs do
member do
get 'accept'
get 'decline'
get 'print_friendly'
end
collection do
post 'create_job_with_estimate'
put 'update_multiple'
end
resources :residential_job_changes do
member do
get 'approve'
end
end
end
resources :home_owners
resources :prop_managers
resources :contractors do
member do
get 'approve'
get 'disapprove'
end
end
resources :users
resources :email_templates
resources :feedback_survey_questions
resources :decline_reasons
resources :services
resources :branches
resources :sessions
resources :password_resets
get "sites/index"
get "sites/about_us"
get "sites/home_owner"
get "sites/home_owner_front"
get "sites/prop_manager"
get "sites/owner_register"
get "login" => "sessions#new", :as => "login"
get "logout" => "sessions#destroy", :as => "logout"
end
すでにルートを正しく定義していると思いますので、変更が必要な場合はお知らせください。