如何使用rails选择基于最常见字段的数据库值

时间:2014-06-06 10:07:01

标签: ruby-on-rails

def selected
    @enquiries = Enquiry.all 
    @enquiry_details = EnquiryDetail.all
    @comments = Comment.all
    @enquiries.where("created_at >= ? AND created_at <= ?", Time.zone.now.beginning_of_day, Time.zone.now.end_of_day)

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @enquiries and @enquiry_details and @comments  }
    end  
  end

如何在我的视图中调用此方法。

<%= link_to '<button type="button">SELECT</button>'.html_safe, method: :selected %>

1 个答案:

答案 0 :(得分:0)

selected 操作创建路线,然后执行此操作;

<%= button_to "SELECT", { :controller => "CONTROLLER", :action => "selected"} %>