i try to spend a variable in my partial
i try to spend a variable in my partial _showLastMeal.rb, before to come
for asking your help i read http://api.rubyonrails.org and i try to find a
solution in staskoverflow
<%= render :partial => "calendars/showLastMeal", :locals => { :calendar =>
"calendar" } -%>
In calendar_controller.rb:
def showLastMeal
@lastMeal = @user.calendar.findMeal
end
And the model
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
i use rails 3.2.2
No comments:
Post a Comment