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

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

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

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

Q&A

解決済

1回答

4806閲覧

ビューとコントローラーが作れないのはどうしてでしょうか?

manman

総合スコア233

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

0グッド

0クリップ

投稿2016/02/13 16:26

編集2016/02/14 02:00

OS:windows10

http://openbook4.me/projects/92/sections/488
を見ながら、
rails g controller users index show
を実行したところ、

Could not find gem 'sass-rails (~> 5.0) x64-mingw32' in any of the gem sources listed in your Gemfile or available on this machine. Run `bundle install` to install missing gems.

というメッセージが出たので、
bundle install
を実行したのですが、再び

Could not find gem 'sass-rails (~> 5.0) x64-mingw32' in any of the gem sources listed in your Gemfile or available on this machine. Run `bundle install` to install missing gems.

というエラーが出てきます。
どのようにビューとコントローラーを作ればよいか教えてください。

(追記)
bundle install を繰り返すと以下のエラーがでてきました。

Fetching gem metadata from https://rubygems.org/........... Fetching version metadata from https://rubygems.org/... Fetching dependency metadata from https://rubygems.org/.. Resolving dependencies............. Using rake 10.5.0 Using i18n 0.7.0 Installing json 1.8.3 with native extensions Gem::InstallError: The 'json' native gem requires installed build tools. Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit' Using minitest 5.8.4 Using thread_safe 0.3.5 Using builder 3.2.2 Using erubis 2.7.0 Using mini_portile2 2.0.0 Using rack 1.6.4 Using mime-types 2.99 Using arel 6.0.3 Installing debug_inspector 0.0.2 with native extensions Gem::InstallError: The 'debug_inspector' native gem requires installed build tools. Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit' Using bundler 1.11.2 Installing byebug 8.2.2 with native extensions Gem::InstallError: The 'byebug' native gem requires installed build tools. Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit' Using coffee-script-source 1.10.0 Using execjs 2.6.0 Using thor 0.19.1 Using concurrent-ruby 1.0.0 Using multi_json 1.11.2 Using sass 3.4.21 Using tilt 2.0.2 Using sqlite3 1.3.11 An error occurred while installing json (1.8.3), and Bundler cannot continue. Make sure that `gem install json -v '1.8.3'` succeeds before bundling.

DEVELOPMENT KITインストール後

C:\devkit>ruby dk.rb init Initialization complete! Please review and modify the auto-generated 'config.yml' file to ensure it contains the root directories to all of the installed Rubies you want enhanced by the DevKit. C:\devkit>ruby dk.rb install Invalid configuration or no Rubies listed. Please fix 'config.yml' and rerun 'ruby dk.rb install' C:\devkit>

というエラーが出ています。config.yml をどう編集すればよいでしょうか?

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

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

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

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

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

guest

回答1

0

ベストアンサー

下記のサイトを参考にDevKitをインストール(展開して、config.ymlを編集して、ruby devkit.rb installを実行)して下さい。DevKitはRuby Installerのサイトからダウンロードできます。
http://qiita.com/shimoju/items/41035b213ad0ac3a979e
http://www.rubylife.jp/railsinstall/rails/index4.html
http://yohshiy.blog.fc2.com/blog-entry-240.html
※ 64bit版をお使いのようですので、DevKitは DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe を入れて下さい。


疑問についての解説していきます。

bundle installはRailsで必要になるRubyの拡張ライブラリをインストールするコマンドです。Gemfilesというファイルに必要なライブラリが記載されており、その依存関係を含めて自動で全てインストールしてくれます。逆に言うと必要なライブラリが欠けていると、正常に動作することが出来ません。bundle installが成功しない限り、Railsが動くことはないでしょう。

Rubyの拡張ライブラリの作りには大きく二種類あります。Rubyのみで書かれたライブラリと、C言語※で書かれたライブラリです。Rubyのみで書かれたライブラリはすぐに利用可能ですが、C言語で書かれたライブラリはコンパイルする必要があります。ライブラリによってはコンパイル済みのファイルも配付されている場合がありますが、ほとんどの場合は、必ずC言語のコンパイラが必要になります。例えば、Linuxではyumやapt-get等でgcc等をインストールしておく必要がありますし、MacであればXcodeをインストールしておく必要があります。
※ C言語だけでなくC++言語等の任意の言語で作成可能ですが、インターフェース部分はC言語です。またJRuby用のJavaで書かれたライブラリも存在します。

Windowsの場合は更にちょっと複雑です。WindowsでC言語をコンパイルする場合、主に3つのコンパイラがあります。

  • Visual C++ (Visual Studioについてきます)
  • Mingw版 GCC (いくつか種類があります)
  • Cygwin版 GCC

Ruby本体もこれらのコンパイラのどれか一つを用いて、コンパイルされています。そして、拡張ライブラリはRuby本体に使用したコンパイラと同じコンパイラでコンパイルする必要があります。Ruby Installerの場合は、DevKitとして配付されているMingw版 GCCですのでDevKitが必要になります。もし、ActiveScriptRubyでしたら、Visual C++を使用していますので、Visual C++が必要になります。これらはどのRubyをインストールしたかによって異なるため、注意して下さい。

投稿2016/02/13 22:22

編集2016/02/13 22:23
raccy

総合スコア21735

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

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

manman

2016/02/14 02:18

後、config.yml にrubyのパスを書き込むとうまくいきました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問