質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

2469閲覧

Railsのエラーunexpected tIDENTIFIER, expecting keyword_then or ';' or '\n' の解決方法について教えてください。

koume

総合スコア458

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2017/10/19 08:33

Rails5.1.3でWebアプリケーション制作の勉強中です。簡単なエラーだと思うのですが、何が原因かわからないのでどなたか
教えていただけないでしょうか? エラー と コードの内容は以下になります。

SyntaxError (/home/vagrant/chibi/chibi/app/controllers/customer/scores_controlle r.rb:117: syntax error, unexpected tIDENTIFIER, expecting keyword_end /home/vagrant/chibi/chibi/app/controllers/customer/scores_controller.rb:119: syn tax error, unexpected tIDENTIFIER, expecting keyword_end /home/vagrant/chibi/chibi/app/controllers/customer/scores_controller.rb:152: syn tax error, unexpected tIDENTIFIER, expecting keyword_then or ';' or '\n' /home/vagrant/chibi/chibi/app/controllers/customer/scores_controller.rb:162: syn tax error, unexpected keyword_end, expecting end-of-input):
class Customer::ScoresController < Customer::Base def show score = Score.find_by(customer_id: current_customer.id) data = score.attributes time = Time.now @month = time.month @mpt = data["sc_#{@month}"] @customer = Customer.find_by(id: current_customer.id) eagle = @customer.nickname @ccc = Sponsor.where(sponsor1:eagle).pluck(:customer_id) @ddd = @ccc.length eee = [] @ccc.each do |r| @coala = Register.find_by(customer_id: r) register_check if fox == "在籍" eee << r end @fff = eee.length if @ddd == @fff else jjj = @ccc - eee if month == 1 fox = @coala.jan elsif @month == 2 fox = @coala.feb elsif @month == 3 fox = @coala.mar elsif @month == 4 fox = @coala.apr elsif @month == 5 fox = @coala.may elsif @month == 6 fox = @coala.jun elsif @month == 7 fox = @coala.jul elsif @month == 8 fox = @coala.aug elsif @month == 9 fox = @coala.sep elsif @month == 10 fox = @coala.oct elsif @month == 11 fox = @coala.nov else fox = @coala.dec end jjj.each do |t| hhh = Customer.find(t) iii = hhh.nickname aaa = Sponsor.where(sponsor1: iii).pluck(:customer_id) kkk = [] vvv = [] aaa.each do |u| @coala = Ragister.find_by(customer_id: u) register_check if fox == "在籍" kkk << u end if fox == "不在" vvv << u end end end end if kkk != "nil" eee << r else register_check  end if kkk != "nil" eee << r else register_check  end if kkk != "nil" eee << u else register_check  end if kkk != "nil" eee << u else register_check  end if kkk != "nil" eee << u else register_check end if kkk != "nil" eee << u end end @lily = eee.length end def register_check vvv.each do |t| hhh = Customer.find(t)   #117行目  iii = hhh.nickname aaa = Sponsor.where(sponsor1: iii).pluck(:customer_id)  # 119行目  kkk = [] vvv = [] aaa.each do |u| @coala = Ragister.find_by(customer_id: u) if month == 1 fox = @coala.jan elsif @month == 2 fox = @coala.feb elsif @month == 3 fox = @coala.mar elsif @month == 4 fox = @coala.apr elsif @month == 5 fox = @coala.may elsif @month == 6 fox = @coala.jun elsif @month == 7 fox = @coala.jul elsif @month == 8 fox = @coala.aug elsif @month == 9 fox = @coala.sep elsif @month == 10 fox = @coala.oct elsif @month == 11 fox = @coala.nov else fox = @coala.dec end if fox == "在籍"   #152行目  kkk << u end if fox == "不在" vvv << u end end end end end      # 162行目

初心者のためコードがごちゃごちゃしていますがエラーの解決方法を教えていただけないでしょうか?
それとregister_checkメソッドの読み込みは、単純にコードの中にregister_checkと記述しただけで読み込んでくれるのでしょうか?
宜しくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

コードの内容があまりにも間違いが多かったのでいったん取り消します。

投稿2017/10/19 11:34

koume

総合スコア458

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問