English 中文(简体)
我在铁路上产生了新的行动,但我不知道如何与适当的观点联系起来。
原标题:I ve created a new action in rails but I don t know how to connect to an appropriate view

我为罗里的一个现有实体(模型/控制器/概览)以及行动工作建立了搜索行动,但浏览器给我留下了有关缺失模板的错误,现在我想添加一个显示结果的模板(概览)。

这里像我的网站那样简单:

b)- 在我界定“研究”行动的地方

app/models/item.rb <-- where I define the search function

app/views/items/_search_result.html.haml <---在其中,我仅复制一个简单的“hello world”,而那儿,它不工作

并且是模式中的功能:

 def self.search(search)
   search_condition = "%" + search + "%"
   find(:all , :conditions => [ product_name LIKE ? or details LIKE ? ,search_condition , search_condition])
 end

并且是控制者的行动:

def search
  @item = Item.search params[:search]
end

我应如何得出结果?

最佳回答

Rename

app/views/items/_search_result.html.haml

纽约总部

app/views/items/search.html.haml
问题回答

暂无回答




相关问题
Remove ActiveRecord in Rails 3

Now that Rails 3 beta is out, I thought I d have a look at rewriting an app I have just started work on in Rails 3 beta, both to get a feel for it and get a bit of a head-start. The app uses MongoDB ...

When will you upgrade your app to Rails 3? [closed]

Now that the Rails 3 beta is here, let s take a little straw poll. Please tell us briefly what your application does and when you will upgrade it to Rails 3. Or, if you re not planning on upgrading ...

Bundler isn t loading gems

I have been having a problem with using Bundler and being able to access my gems without having to require them somewhere, as config.gem used to do that for me (as far as I know). In my Rails 3 app, I ...

bypass attr_accessible/protected in rails

I have a model that, when it instantiates an object, also creates another object with the same user id. class Foo > ActiveRecord::Base after_create: create_bar private def create_bar Bar....

concat two fields activerecord

I m so used to oracle where you can simply concat(field1, , field2) but if I m using activerecord to find the field1 and field2, and I need a space in between, how do I accomplish this? Cheers ...

热门标签