class PublicController < ApplicationController
def album_list
@albums = Album.find_by_sql('SELECT * FROM albums;')
end
def alt_album_list
@albums = Album.find(:all)
render(:action => 'album_list')
end
def show_album
@album = Album.find(:first)
end
def show
@album = Album.find(params[:id])
render(:action => 'show_album')
end
def new
@album = Album.new
end
这是我的溃败:
MusicLibrary::Application.routes.draw do
resources :albums
resources :public
get "public/album_list"
get "public/alt_album_list"
get "public/one_album_list"
get "public/show_album"
get 'public/show'
get 'public/create'
get 'public/new'
get 'public/edit'
模型 :
<html>
<head>
<title> Interesting </title>
</head>
<body>
<%= form_for(@album) do |f| %>
<p>
<%= f.label :title %>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :artist %>
<%= f.text_field :artist %>
</p>
<p>
<%= f.label :genre %>
<%= f.text_field :genre %>
</p>
<p>
<%= f.label :release_date %>
<%= f.datetime_select :release_date %>
</p>
<%= f.submit %>
<% end %>
</body>
</html>
我有一个错误 LIKE :Couldn't find [model] with ID rails 4
我知道这可以很简单controller
,model
和 view ,但由于该错误它不起作用。我没有复制整个内容,Controller
因为它没用。其余代码看起来不错并且工作正常,但是...