我遇到了这样的错误,我是 Rails 的新手。
我的路线.rb
Rails.application.routes.draw do
get 'welcome' => 'page#search'
resources :songs
end
搜索.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) 页面#search song_new_path POST /song/new(.:format) song#new song_path GET /songs(.:format) song#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