私のphotos.rb
ファイルには次のものがあります。
ActiveAdmin.register Photo do
form :partial => 'admin/forms/photo', :locals => { :events => Event.all }
end
私の_photo.html.erb
ファイルでは、イベントの値にアクセスできるようにしたいのですが、検出できないようです。これどうやってするの?
コメントで要求されたように、ここに私のフォームがあります:
<% if events.any? %>
<%= form_for [:admin, @photo], :validate => true do |f| %>
<!-- insert a bunch of standard field divs here -->
<div class="actions" style="margin-top: 20px">
<% if @photo.new_record? %>
<%= f.submit 'Create photo' %>
<% else %>
<%= f.submit 'Update photo' %>
<% end %>
</div>
<% end %>
<% else %>
<div style="font-size: 14px">
You cannot add photos until you have added at least one event.
</div>
<% end %>
私が得ているエラーメッセージは次のevents.any?
行です。
Completed 500 Internal Server Error in 108ms
ActionView::Template::Error (undefined local variable or method `events' for #<#<Class:0x007fdb8e841b80>:0x007fdb8a93e7a8>)