2017-11-17 20 views
0

私は最初のルビーをレールアプリにしようとしています。私はルビーでもレールでも経験がありません。私は答えを見つけようとしましたが、それは成功しませんでした。Rails:TypeError:オブジェクトはこのプロパティまたはメソッドをサポートしていません

私のエラーは次のとおりです。 C:/Sites/projects/test/app/views/layouts/application.html.erbライン#10が提起: 例外TypeError:オブジェクトはこのプロパティまたはメソッド 抽出されたソースをサポートしていません。 (ライン#10前後)

マイapplication.html.erb:

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Test</title> 
    <%= csrf_meta_tags %> 

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.css"> 
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.css"> 

    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 
    </head> 

    <body> 
    <div class="container"> 
    <%= yield %> 
</div> 
    </body> 
</html> 

マイgemfile:

source 'https://rubygems.org' 
    git_source(:github) do |repo_name| 
     repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 
     "https://github.com/#{repo_name}.git" 
    end 


    # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
    gem 'rails', '~> 5.1.4' 
    # Use sqlite3 as the database for Active Record 
    gem 'sqlite3' 
    # Use Puma as the app server 
    gem 'puma', '~> 3.7' 
    # Use SCSS for stylesheets 
    gem 'sass-rails', '~> 5.0' 
    # Use Uglifier as compressor for JavaScript assets 
    gem 'uglifier', '>= 1.3.0' 
    # See https://github.com/rails/execjs#readme for more supported runtimes 
    # gem 'therubyracer', platforms: :ruby 

    # Use CoffeeScript for .coffee assets and views 
    gem 'coffee-rails', '~> 4.2' 
    # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 
    gem 'turbolinks', '~> 5' 
    # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
    gem 'jbuilder', '~> 2.5' 
    # Use Redis adapter to run Action Cable in production 
    # gem 'redis', '~> 3.0' 
    # Use ActiveModel has_secure_password 
    # gem 'bcrypt', '~> 3.1.7' 

    # Use Capistrano for deployment 
    # gem 'capistrano-rails', group: :development 

    group :development, :test do 
     # Call 'byebug' anywhere in the code to stop execution and get a debugger console 
     gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 
     # Adds support for Capybara system testing and selenium driver 
     gem 'capybara', '~> 2.13' 
     gem 'selenium-webdriver' 
    end 

    group :development do 
     # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 
     gem 'web-console', '>= 3.3.0' 
    end 

    # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 
    gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 

RoのUTEファイル:

Rails.application.routes.draw do 
    root to: redirect('/ideas') 
    resources :ideas 
    # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 
end 

とコントローラ:

class ApplicationController < ActionController::Base 
    protect_from_forgery with: :exception 
end 

class IdeasController < ApplicationController 
    before_action :set_idea, only: [:show, :edit, :update, :destroy] 

    # GET /ideas 
    # GET /ideas.json 
    def index 
    @ideas = Idea.all 
    end 

    # GET /ideas/1 
    # GET /ideas/1.json 
    def show 
    end 

    # GET /ideas/new 
    def new 
    @idea = Idea.new 
    end 

    # GET /ideas/1/edit 
    def edit 
    end 

    # POST /ideas 
    # POST /ideas.json 
    def create 
    @idea = Idea.new(idea_params) 

    respond_to do |format| 
     if @idea.save 
     format.html { redirect_to @idea, notice: 'Idea was successfully created.' } 
     format.json { render :show, status: :created, location: @idea } 
     else 
     format.html { render :new } 
     format.json { render json: @idea.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # PATCH/PUT /ideas/1 
    # PATCH/PUT /ideas/1.json 
    def update 
    respond_to do |format| 
     if @idea.update(idea_params) 
     format.html { redirect_to @idea, notice: 'Idea was successfully updated.' } 
     format.json { render :show, status: :ok, location: @idea } 
     else 
     format.html { render :edit } 
     format.json { render json: @idea.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # DELETE /ideas/1 
    # DELETE /ideas/1.json 
    def destroy 
    @idea.destroy 
    respond_to do |format| 
     format.html { redirect_to ideas_url, notice: 'Idea was successfully destroyed.' } 
     format.json { head :no_content } 
    end 
    end 

    private 
    # Use callbacks to share common setup or constraints between actions. 
    def set_idea 
     @idea = Idea.find(params[:id]) 
    end 

    # Never trust parameters from the scary internet, only allow the white list through. 
    def idea_params 
     params.require(:idea).permit(:name, :description, :picture) 
    end 
end 

私はすでにapplication.html.erbにデフォルトでアプリケーションを置き換えるためにしようとしました。

答えて

0

私は助けるかもしれないフラグが立てられてきた同様の質問があります - 彼らのソリューションは、以下の通りであった:

I removed the require_tree from application.js and it worked

//= require jquery
//= require jquery_ujs
//= require turbolinks
// require_tree .

あなたのjavascript内の問題がどこかにあります示唆していること - このアプローチが機能するかどうか、私は探したいですそこには何かがあります。そして/または1つずつ追加してください。

私が試してみたいことは、あなたのjavascript_include_tagのTurbolinksオプションを取り除くことで、それが何かを狂わせているかどうかを確認することです。

これが役立つ場合はお知らせください。


編集:

直接の回答で他のスレッドをリンクするには、それはここにある:カップルより多くのそれを分岐して

TypeError: Object doesn't support this property or method

Rails ExecJS::ProgramError in Pages#home?

ExecJS::RuntimeError on Windows trying to follow rubytutorial

読書の公正なビット:)

+0

それは動作します!大いに感謝する! – Svetlana

+0

ようこそ - 私は助けることができてうれしい:) – SRack

関連する問題