0

我尝试在我的部分中花费一个变量_showLastMeal.rb,在来寻求您的帮助之前我阅读了http://api.rubyonrails.org并尝试在 staskoverflow 中找到解决方案

<%= render :partial => "calendars/showLastMeal", :locals => { :calendar => "calendar" }  -%>

calendar_controller.rb

def showLastMeal
  @lastMeal = @user.calendar.findMeal
end

和模型

 class Calendar < ActiveRecord::Base
   attr_accessible :event, :published_on, :description, :user_id, :description_meal
   belongs_to :user #, :foreign_key => :user_id
   scope :findMeal, lambda { order('created_at').limit(6) }
 end

我使用导轨 3.2.2

4

0 回答 0