我托管的服务器上运行的Rails 2.3.5,并且无法升级到3如何让Rails select()工作?
我有一个数据库,它有卡通与id
,date
和title
列表。我可以使用文本链接浏览它们,我也希望能够使用下拉菜单select
进行导航,但我无法使select
标签正常工作。这不是创建新元素的表单。而form
(空)显示,select
标记不显示,甚至没有空的select
标记。
这是我有:
* comics_controller.rb *
class ComicsController < ApplicationController
before_filter :get_all_comics
def get_all_comics
@comics=Comic.find(:all, :order => "date DESC")
end
def view
if params[:id].nil?
@[email protected]
@[email protected][1]
else
@comic=Comic.find(params[:id])
@prev=Comic.find(:first, :conditions => ["date < ?", @comic.date],
:order => "date DESC")
@next=Comic.find(:first, :conditions => ["date > ?", @comic.date],
:order => "date ASC")
end
end
end
漫画/ view.html.erb
<% form_for :comics, :url => { :action => "view" } do |f|
f.select(:id,Comic.all,:prompt => true)
end %>
<img src="directory/<%= @comic.filename %>" />
<p class="title"><%= @comic.title %></p>
<p class="date"><%= @comic.date %></p>
<% unless @prev.nil? %>
<a href="<%= @prev.id %>">Previous</a>
<% end
unless @next.nil? %>
<a href="<%= @next.id %>">Next</a>
<% end %>
对不起,无法回答你的问题。但我会说使用旧版本来熟悉框架是一个坏主意。我建议你尝试heroku.com托管。您可以免费使用它进行开发和测试。 – bassneck 2011-06-06 17:33:17