Đây là hình thức của tôi phần:Rails: Làm thế nào để xác định bộ điều khiển/hành động theo quan điểm
<%= f.simple_fields_for :photo_attributes, :html => { :multipart => true } do |d| %>
<%= d.label :image, :label => 'Upload logo', :required => false %>
<%= d.file_field :image, :label => 'Image, :required => false', :style => 'margin-bottom:2px' %>
<%= d.input :image_url, :label => 'Billed URL', :required => false %>
<% end %>
Nếu hành động là chỉnh sửa tôi muốn hiển thị này thay vì:
<%= f.simple_fields_for :photo, :html => { :multipart => true } do |d| %>
<%= d.label :image, :label => 'Upload logo', :required => false %>
<%= d.file_field :image, :label => 'Image, :required => false', :style => 'margin-bottom:2px' %>
<%= d.input :image_url, :label => 'Billed URL', :required => false %>
<% end %>
Làm thế nào tôi có thể đạt được điều này ?
này nên được sự chấp nhận answer-- 'current_page?' thật tuyệt vời. – thekingoftruth
Hmm. Tôi đã nhìn thấy những trường hợp nó không hoạt động như mong đợi. tức là khi 'controller_name == 'site'' và' action_name ==' home'' nhưng 'current_page? (controller: 'site', action: 'home')' trả về false. – thekingoftruth
Đồng ý. Câu trả lời này chính xác là những gì bạn đang tìm kiếm. –