たれみみマンデー

Railsでプロセスが切れないときの対処法

Rails(ローカル)でサーバ立ち上げた後うまくプロセスを切れないとき、

調べるとたくさん、

ps aux | grep rails, kill -9 **プロセス番号**

がでてきますが、

kill: (*****) - No such process

と出てくるので、解決法。

lsof -wni tcp:3000

kill -9 **プロセス番号**

で解決。

 

たれみみ(@taremimi_7)

rake aborted! Uglifier::Error: Unexpected character '`' のエラー

サーバー側でrake assets:precompile RAILS_ENV=production すると

rake aborted!

Uglifier::Error: Unexpected character '`'

 

のエラーが。

 

app/assets/javascripts/application.jsの中のjsで使っていた変数展開のバッククォートが問題だったらしいです。

 

<解決策>

config/environments/production.rbで

config.assets.js_compressor = :uglifier

コメントアウト

 

ついでに、直接的には関係ないですが、以下でリフレッシュ(削除)できるらしいです。

rake assets:clobber RAILS_ENV=production

 

たれみみ(@taremimi_7)

 

【Rails】1個前のcontrollerとactionを取得する

1個前のcontrollerとactionを取得する。

 

url = Rails.application.routes.recognize_path(request.referrer)

previous_controller =url[:controller]

previous_action = url[:action]

 

 

たれみみ(@taremimi_7)

redirect_to にcontroller,action,id指定しつつflashを追加

Railsのコントローラー内の話。

redirect_to にcontroller,action,id指定しつつflashを追加する場合、

 

redirect_to ({controller: '****s', action: '****',id: params[:id]}), flash: {success: '更新されました'}

 

({})で囲うの知らなかったのでメモ。

 

 

たれみみ(@taremimi_7)

AWSでMysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)のエラー

1.mysql_config --socketmysqlのソケット位置確認

2.confid/database.yml内で socket=**1の結果** を記述

 

3.mysql --help | grep my.cnf でmy.confの位置確認

 

4.でてきたファイルを1こずつ開いて、すでに中に何か書いてあるファイルの中に

[mysqld]

socket=**1の結果***

[client]

socket=**1の結果***

を記述。

 

5. sudo mysql.server reload  MySQLを再起動

(参考:https://qiita.com/itooww/items/13055c8bb1d226ee5844)

(※ローカルマシンなら→ sudo mysql.server restartこれも有効かも )

以上

これでもわかんないことあったらツイッターでぼくに聞いてください!
たれみみ
@taremimi_7

Devise取り消す作業

 

メモ

Use the generator to remove configuration files as well (step 2), so the whole process would be (referencing previous answers):

  1. Remove the table: rake db:rollback VERSION=<insert the version number of the migration>
  2. Remove the configuration: rails destroy devise:install
  3. Remove your User model: rails destroy devise User (replace 'User' with the name of your model)
  4. Remove references to devise in your routes.rb, gemfile, controller files, and view files like the following, if you used them (once again replacing 'user' with your model name):
    • devise_for (routes.rb)
    • gem 'devise' (gemfile)
    • before_action :authenticate_user! (controllers)
    • user_signed_in? (controllers, views)
    • current_user (controllers, views)
    • user_session (controllers, views)

confi/routes.rb の中のdevise関係削除する

 

引用元: Ruby: how to uninstall Devise? - Stack Overflow