如何将以下程式码转换成Rails1.2格式,因为在Rails1.2无法辨识“timeformats_path”
(views\timeformats\index.html.erb)
Listing timeformats
<% form_tag timeformats_path , :method => 'get' do %>
<%= text_field_tag :search , params[:serach] %>
<%= submit_tag "Search" , :title => nil %>
<% end %>
Title | Datetime | |||
---|---|---|---|---|
'Are you sure?', :method => :delete %> |
<%= link_to 'New timeformat', new_timeformat_path %>
(app\controllers\timeformats_controller.rb)
class TimeformatsController < ApplicationController
# GET /timeformats
# GET /timeformats.xml
def index
@timeformats = Timeformat.search(params[:search])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @timeformats }
end
end
(app\models\timeformat.rb)
class Timeformat < ActiveRecord::Base
validates_presence_of :title
def self.search(search)
if search
find(:all , :conditions => ['title LIKE ?' , "%#{search}%"])
else
find(:all)
end
end