LoginSignup
0
0

More than 5 years have passed since last update.

Ruby on RailsをWindowsで開発したとき躓いたところメモ

Last updated at Posted at 2019-03-21

最初に

今、Ruby on Railsを勉強中なのでやりながら随時更新していこうと思います。

使っているバージョン

ruby 2.4.5p335
Rails 5.2.2.1

Rubyのバージョンが2.5.xだとsqliteをgemできない

上記の記事にもある通りsqliteをうまく導入できませんでした。
自分はおとなしくRuby2.4をインストールし直しました。
またsqlite3のバージョンを指定

# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.3.6'

今使っているバージョンでは問題なく導入できました。

Bootstrap4を導入する際にエラーが発生

以下の手順で導入しました。

  1. Gemfileに追記
# 以下を追加
gem 'bootstrap', '~> 4.1.1'
gem 'jquery-rails', '~> 4.3.1'
  1. bundle install で追加
  2. app/assets/stylesheets下のapplication.cssをapplication.scssに変更
  3. application.scssの中身をすべて消して以下を追記
application.scss
@import "bootstrap";
  1. app/assets/javascripts/application.jsに以下を追記
application.js
//= require jquery3
//= require popper
//= require bootstrap-sprockets

ここでエラー

ActionView::Template::Error (undefined not callable)
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>

解決するためにやったこと

ここのコメントにあるようにGemfileのduktapeを消してnode.jsをinstallしました

# 削除
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'duktape'

もともとnode.jsをインストールしていたので、インストールしていなくても動くかもしれません。

メール送信機能の実装

エラー内容

[ActiveJob] [ActionMailer::Parameterized::DeliveryJob]
[c8d10239-8465-4730-988a-2f0e46f67222] 
Error performing ActionMailer::Parameterized::DeliveryJob 
(Job ID: c8d10239-8465-4730-988a-2f0e46f67222) from Async(mailers) in 481.15ms: 
ActionView::Template::Error 
(Missing host to link to! Please provide the :host parameter,
 set default_url_options[:host], or set :only_path to true):

この記事を参考にメール送信を実装しようとしたのですが、うまく送れませんでした。
調べたところ、エラーログの通りhostが設定されていないのが原因のようです。

development.rb
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default_url_options = 
      { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    port:                 587,
    address:              'smtp.gmail.com',
    domain:               'gmail.com',
    user_name:            'gmailのメールアドレス',
    password:             'gmailのパスワード',
    authentication:       'login',
    enable_starttls_auto: true
  }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0