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

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

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

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

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Ruby on Rails

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

Q&A

0回答

1458閲覧

rails 動画はMSQLで保存されているが、再生できない

takaaki_deguchi

総合スコア4

Ruby

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

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Ruby on Rails

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

0グッド

2クリップ

投稿2019/09/25 05:03

前提・実現したいこと

rails で動画投稿アプリを作成中です。
現在、投稿完了するとMYSQLにはvideoカラムにデーターが保存されているのですが、
再生するページ(index.html.erbなど)での再生ができない状態です。
他のカラムの値はMYSQLに保存され、表示されるべきページに表示されています。

該当のソースコード

コントローラー

class ProductsController < ApplicationController before_action :move_to_index, except: [:index,:show] def index # @products = Product.includes(:user).order("created_at DESC") # @bob = Product.where(stylegenre_id: 1) @bob_style = Product.where(stylegenre_id: 1).order("id DESC").limit(3) @short_style = Product.where(stylegenre_id: 2).order("id DESC").limit(3) @mid_style = Product.where(stylegenre_id: 3).order("id DESC").limit(3) @semlong_style = Product.where(stylegenre_id: 4).order("id DESC").limit(3) @long_style = Product.where(stylegenre_id: 5).order("id DESC").limit(3) @superlong_style = Product.where(stylegenre_id: 6).order("id DESC").limit(3) @hairset_style = Product.where(stylegenre_id: 7).order("id DESC").limit(3) # @stylegenres = Product.all.order("created_at DESC") end def new @product = Product.new end def create Product.create(product_params) redirect_to root_path end def edit @product = Product.find(params[:id]) end def update product = Product.find(params[:id]) if product.user_id == current_user.id product.update(link_url:product_params[:link_url],shop_name:product_params[:shop_name],video:product_params[:video],text:product_params[:text],item_id:product_params[:item_id],cosme:product_params[:cosme],stylegenre_id:params[:stylegenre_id],color_id:params[:color_id],perm_id:params[:perm_id],user_id: current_user.id) end redirect_to root_path end def destroy product = Product.find(params[:id]) if product.user_id == current_user.id product.delete redirect_to root_path end end def show @product = Product.find(params[:id]) @item = Item.find(@product.item_id) @color = Color.find(@product.color_id) @perm = Perm.find(@product.perm_id) @stylegenre = Stylegenre.find(@product.stylegenre_id) end def search @products = Product.includes(:user).page(params[:page]).per(9).order("created_at DESC") end private def product_params params.require(:product).permit(:link_url,:shop_name,:video,:text,:stylest_name,:cosme).merge(stylegenre_id:params[:stylegenre_id],color_id:params[:color_id],perm_id:params[:perm_id],item_id: params[:item_id],user_id: current_user.id) end def move_to_index redirect_to action: :index unless user_signed_in? end end

ビュー(index)

.genres-link .bob-style ボブ .bob-contents - @bob_style.each do |style| .one-index-contents .shop_name-index 店名: = style.shop_name .video-index-product = video_tag style.video_url.to_s,loop: true, controls: true, width: 300,class:"mv" %i.far.fa-clipboard.index-icon = link_to '詳細',"/products/#{style.id}" .short-style ショート .short-contents - @short_style.each do |style| .one-index-contents .shop_name-index 店名: = style.shop_name .video-index-product = video_tag style.video_url.to_s,loop: true, controls: true, width: 300,class:"mv" %i.far.fa-clipboard.index-icon = link_to '詳細',"/products/#{style.id}",class:"stylename"

ビュー(new)

.one-new-product = form_for @product do |f| %h3 掲載する .new-form = f.label :店名(必須),class:"out-label" = f.text_field :shop_name,class:"text-box" .error-new-1 .new-form = f.label :説明文(必須),class:"form-label" = f.text_field :text,class:"text-box" .error-new-2 .new-form = f.label :動画(必須),class:"video-label" = f.file_field :video,class:"video-form" .error-new-3 .new-form = f.label :スタイリスト名(必須),class:"form-label" = f.text_field :stylest_name,class:"text-box" .error-new-4 .new-form = f.label :コスメ,class:"out-label" = f.text_field :cosme,class:"text-box" .error-new-9 .new-form = f.label :リンク,class:"out-label" = f.text_field :link_url,class:"text-box" .error-new-10 .new-item-form = f.label :スタイル(必須),class:"select-label" %select.stylename-select-box{name: "stylegenre_id"} %option{value: ""} ---- %option{value: 1} ボブ %option{value: 2} ショート %option{value: 3} ミディアム %option{value: 4} セミロング %option{value: 5} ロング %option{value: 6} スーパーロング %option{value: 7} ヘアセット .error-new-5 .new-item-form = f.label :アイテム(必須),class:"select-label" %select.items-select-box{name: "item_id"} %option{value: ""} ---- %option{value: 1} ストレートアイロン %option{value: 2} コテ32mm %option{value: 3} コテ28mm %option{value: 4} コテ18mm %option{value: 5} コテ16mm %option{value: 6} ヘアゴム %option{value: 7} なし .error-new-6 .new-item-form = f.label :カラー(必須),class:"select-label" %select.items-select-box{name: "color_id"} %option{value: ""} ---- %option{value: 1}

モデル

class Product < ApplicationRecord mount_uploader :video, VideoUploader mount_uploader :image, ImageUploader belongs_to :user belongs_to :item belongs_to :color belongs_to :perm belongs_to :stylegenre validates :text, presence: true validates :shop_name, presence: true validates :stylest_name, presence: true validates :video, presence: true end

モデル(video_uploader)

class VideoUploader < CarrierWave::Uploader::Base def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end end

試したこと

モデルのアソシエーションの確認

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

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

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

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

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

odyu

2019/10/01 09:51

ブラウザのネットワークではエラーは出ていますか? 404エラーとか
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問