Webアプリの学習をしながら制作をしております。ある程度のところまでできて動作確認をしようとしたらエラーが出てしまい
エラー内容を検索しても解決策がわからなかったのでどなたか教えていただけないでしょうか?エラ-内容とコードは以下になります。
SyntaxError in Staff::CustomersController#edit /home/vagrant/chibi/chibi/app/forms/staff/customer_form.rb:5: syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' delegate :persisted?, :save, to: :customer ^ Extracted source (around line #5): 3 4 attr_accessor :customer, :inputs_home_address, 5 delegate :persisted?, :save, to: :customer 6 7 def initialize(customer = nil) 8 @customer = customer Rails.root: /home/vagrant/chibi/chibi Application Trace | Framework Trace | Full Trace app/forms/staff/customer_form.rb:5: syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' app/controllers/staff/customers_controller.rb:16:in `edit'
指摘されたコード
class Staff::CustomerForm include ActiveModel::Model attr_accessor :customer, :inputs_home_address, delegate :persisted?, :save, to: :customer def initialize(customer = nil) @customer = customer @customer ||= Customer.new(gender: 'male') self.inputs_home_address = @customer.home_address.present? @customer.build_home_address unless @customer.home_address end def assign_attributes(params = {}) @params = params customer.assign_attributes(customer_params) customer.home_address.assign_attributes(home_address_params) end private def customer_params @params.require(:customer).permit( :email, :password, :family_name, :given_name, :family_name_kana, :given_name_kana, :birthday, :gender ) end def home_address_params @params.require(:home_address).permit( :postal_code, :prefecture, :city, :address1, :address2, ) end end
宜しくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/21 00:46