0

そのようなエラーが発生しています。私はレールが初めてです。

私のルート.rb

Rails.application.routes.draw do
get 'welcome' => 'page#search'

resources :songs
end

search.html.erb

<%=form_for @song do |f|%>
<%=f.text_field :search%>
<%=f.submit 'Search'%>
<%end%>

page_controller.rb

class PageController < ApplicationController
attr_accessor :a

def search
  @songs = Song.all
  @song = Song.new
end

def new
  @song = Song.new
end

def Create
  @song = Song.new()
 if @song.save 
  rediect_to ''
 else
  render new
 end
end

 def parameter
  params.require(@song)
 end
end

welcome_path GET /welcome(.:format) page#search song_new_path POST /song/new(.:format) song#new song_path GET /songs(.:format) songs#index POST /songs(.:format) song#create new_song_path GET /songs/new(.:format) 曲#new edit_song_path GET /songs/:id/edit(.:format) 曲#edit song_path GET /songs/:id(.:format) 曲#show PATCH /songs/: id(.:format) 曲#update PUT /songs/:id(.:format) 曲#update DELETE /songs/:id(.:format) 曲#destroy

4

2 に答える 2

1

ルート ファイルで宣言resources :songsしたので、Rails は app/controllers フォルダー内の ApplicationController から継承する SongsController を期待します。このコントローラーがない場合は、新しいファイルを作成します。

app/controller/songs_controller.rb

class SongsController < ApplicationController

  # add implementation of CRUD methods
  def index

  end

  def show

  end

  def new

  end

  # ...
end
于 2015-05-23T11:29:31.493 に答える
0

コントローラーの名前をSongsControllerに変更します

于 2015-05-23T11:29:20.160 に答える