2017-06-24 3 views
1

開発中に私のクライアント側の検証がうまくいっていますが、Herokuにプッシュすると実行されません。 javascriptが正しく動作していないようです。Rails 5のクライアント側の検証がHerokuで機能しない

モデルは、依然として不正な入力を検証し、拒否します。

私は、私が遭遇するすべての解決策を試しているが、役に立たない。私は生産環境のために私の資産をあらかじめコンパイルして、それがうまくいくかどうかを見極めるようにしました。

かなり長い間、Railsを初めて使用していますので、問題を診断するにはコードのどの部分を確認する必要があるのか​​全部は分かりませんが、助けていただければ幸いです。

EDIT:モデルと詳細

私は現在、私はちょうどそれはURLです確実にするために正規表現を使用して入力の有無をチェックしていますclient_side_validations宝石

を使用していますを追加します。ここで

class Url < ApplicationRecord 
    after_create :generate_slug 
    validates :given_url, presence: true 
    validates_format_of :given_url, :with => /(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?\z/ 

    # Convert the ID to base36 to be used as the path 
    def generate_slug 
    self.slug = self.id.to_s(36) 
    self.save 
    end 

    # construct the new URL 
    def display_slug 
    ENV['BASE_URL'] + self.slug 
    end 

end 

は、私の見解では、あなたのアプリ/資産/ JavaScriptの/ application.jsについては

<%= form_for @url, validate: true, remote: true do |f| %> 
    <div class ="input-group"> 
     <label hidden></label> 
     <%= f.text_field :given_url, validate: {presence: true}, :class => "form-control", :placeholder => "Give me a link..." %> 
     <span class="input-group-btn"> 
     <%= f.submit 'Go!', :class => "btn btn-primary btn-lg" %> 
     </span> 
    </div> <!-- input group --> 
<% end %> 

と展開ログ

Total 0 (delta 0), reused 0 (delta 0) 
remote: Compressing source files... done. 
remote: Building source: 
remote: 
remote: -----> Node.js app detected 
remote: 
remote: -----> Creating runtime environment 
remote:   
remote:  NPM_CONFIG_LOGLEVEL=error 
remote:  NPM_CONFIG_PRODUCTION=true 
remote:  NODE_VERBOSE=false 
remote:  NODE_ENV=production 
remote:  NODE_MODULES_CACHE=true 
remote: 
remote: -----> Installing binaries 
remote:  engines.node (package.json): unspecified 
remote:  engines.npm (package.json): unspecified (use default) 
remote:  engines.yarn (package.json): unspecified (use default) 
remote:   
remote:  Resolving node version 6.x via semver.io... 
remote:  Downloading and installing node 6.11.0... 
remote:  Using default npm version: 3.10.10 
remote:  Resolving yarn version (latest) via semver.io... 
remote:  Downloading and installing yarn (0.24.5)... 
remote:  Installed yarn 0.24.5 
remote: 
remote: -----> Restoring cache 
remote:  Loading 2 from cacheDirectories (default): 
remote:  - node_modules (not cached - skipping) 
remote:  - bower_components (not cached - skipping) 
remote: 
remote: -----> Building dependencies 
remote:  Installing node modules (yarn.lock) 
remote:  yarn install v0.24.5 
remote:  [1/4] Resolving packages... 
remote:  [2/4] Fetching packages... 
remote:  [3/4] Linking dependencies... 
remote:  [4/4] Building fresh packages... 
remote:  Done in 0.07s. 
remote: 
remote: -----> Caching build 
remote:  Clearing previous node cache 
remote:  Saving 2 cacheDirectories (default): 
remote:  - node_modules (nothing to cache) 
remote:  - bower_components (nothing to cache) 
remote: 
remote: -----> Build succeeded! 
remote: !  This app may not specify any way to start a node process 
remote:  https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type 
remote: 
remote: -----> Ruby app detected 
remote: -----> Compiling Ruby/Rails 
remote: -----> Using Ruby version: ruby-2.3.4 
remote: -----> Installing dependencies using bundler 1.15.1 
remote:  Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment 
remote:  Fetching gem metadata from https://rubygems.org/......... 
remote:  Fetching version metadata from https://rubygems.org/.. 
remote:  Fetching dependency metadata from https://rubygems.org/. 
remote:  Using rake 12.0.0 
remote:  Using concurrent-ruby 1.0.5 
remote:  Using i18n 0.8.4 
remote:  Using minitest 5.10.2 
remote:  Using thread_safe 0.3.6 
remote:  Using builder 3.2.3 
remote:  Using erubi 1.6.0 
remote:  Using mini_portile2 2.2.0 
remote:  Using rack 2.0.3 
remote:  Using nio4r 2.1.0 
remote:  Using websocket-extensions 0.1.2 
remote:  Using mime-types-data 3.2016.0521 
remote:  Using arel 8.0.0 
remote:  Using method_source 0.8.2 
remote:  Using thor 0.19.4 
remote:  Using bundler 1.15.1 
remote:  Using pg 0.21.0 
remote:  Using puma 3.9.1 
remote:  Using sass 3.4.24 
remote:  Using tilt 2.0.7 
remote:  Using execjs 2.7.0 
remote:  Using coffee-script-source 1.12.2 
remote:  Using turbolinks-source 5.0.3 
remote:  Using multi_json 1.12.1 
remote:  Using regexp_parser 0.4.3 
remote:  Using nokogiri 1.8.0 
remote:  Using websocket-driver 0.6.5 
remote:  Using mime-types 3.1 
remote:  Using tzinfo 1.2.3 
remote:  Using rack-test 0.6.3 
remote:  Using sprockets 3.7.1 
remote:  Using figaro 1.1.1 
remote:  Using uglifier 3.2.0 
remote:  Using autoprefixer-rails 7.1.1.2 
remote:  Using turbolinks 5.0.1 
remote:  Using coffee-script 2.4.1 
remote:  Using mail 2.6.6 
remote:  Using js_regex 1.2.3 
remote:  Using activesupport 5.1.1 
remote:  Using loofah 2.0.3 
remote:  Using rails-dom-testing 2.0.3 
remote:  Using globalid 0.4.0 
remote:  Using activemodel 5.1.1 
remote:  Using jbuilder 2.7.0 
remote:  Using rails-html-sanitizer 1.0.3 
remote:  Using bootstrap 4.0.0.alpha6 
remote:  Using activejob 5.1.1 
remote:  Using activerecord 5.1.1 
remote:  Using actionview 5.1.1 
remote:  Using actionpack 5.1.1 
remote:  Using actioncable 5.1.1 
remote:  Using actionmailer 5.1.1 
remote:  Using railties 5.1.1 
remote:  Using sprockets-rails 3.2.0 
remote:  Using jquery-rails 4.3.1 
remote:  Using coffee-rails 4.2.2 
remote:  Using rails 5.1.1 
remote:  Using sass-rails 5.0.6 
remote:  Using client_side_validations 9.3.3 
remote:  Bundle complete! 20 Gemfile dependencies, 59 gems now installed. 
remote:  Gems in the groups development and test were not installed. 
remote:  Bundled gems are installed into ./vendor/bundle. 
remote:  Bundle completed (2.69s) 
remote:  Cleaning up the bundler cache. 
remote:  Detected manifest file, assuming assets were compiled locally 
remote: 
remote: ###### WARNING: 
remote:  You have not declared a Ruby version in your Gemfile. 
remote:  To set your Ruby version add this line to your Gemfile: 
remote:  ruby '2.3.4' 
remote:  # See https://devcenter.heroku.com/articles/ruby-versions for more information. 
remote: 
remote: ###### WARNING: 
remote:  No Procfile detected, using the default web server. 
remote:  We recommend explicitly declaring how to boot your server process via a Procfile. 
remote:  https://devcenter.heroku.com/articles/ruby-default-web-server 
remote: 
remote: -----> Discovering process types 
remote:  Procfile declares types  -> (none) 
remote:  Default types for buildpack -> console, rake, web, worker 
remote: 
remote: -----> Compressing... 
remote:  Done: 40M 
remote: -----> Launching... 
remote:  Released v25 
remote:  https://fathomless-plateau-97011.herokuapp.com/ deployed to Heroku 
remote: 
remote: Verifying deploy... done. 
+0

あなたは 'dev'でプリコンパイルする必要はありません。プリコンパイルはヒロクで自動的に行われます – illusionist

+0

@illusionistはい私はもともとそれをやっていなかったが、私はそれを提案したいくつかのstackoverflow質問に出くわした。物事を正しく保つためにそれらを取り除きます。 – SkipCloud

+0

モデルの検証をアップロードして、app/models/your_model.rbを開いて、有効でない検証(詳細) – widjajayd

答えて

1
  • だフォームはあなたのことを確認していますhave

    //必要なものrails.valid真再び:

    • 私はあなたがリモート配置する必要はありませんので、AJAXリクエストを処理する宝石を理解するためのフォームのために、真:ations

    • は、サイトのサンプルは、リモート使用する必要を示していません手動でajaxのために

+0

私はリモートを持っています:真投稿したときにページがリロードされず、削除してフォームを送信しますが、その下のビューには短縮URLが入力されません。 – SkipCloud

+0

ああ申し訳ありませんが、あなたのエラーのための他のアイデアはまだありません – widjajayd

+0

問題はありません、とにかく笑を助けてくれてありがとう。これは私を狂ってしまう。 – SkipCloud

関連する問題