This is my form partial:
<%= 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 %>
If the action is edit I want to show this instead:
<%= 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 %>
How can i achieve this?
I fetched this definition from the official rails guide: A controller's purpose is to receive specific requests for the application. Routing decides which controller receives which requests. Often, there is more than one route to each controller, and different routes can be served by different actions.
Action Controllers are the core of a web request in Rails. They are made up of one or more actions that are executed on request and then either it renders a template or redirects to another action.
1 What is Action View? In Rails, web requests are handled by Action Controller and Action View. Typically, Action Controller is concerned with communicating with the database and performing CRUD actions where necessary. Action View is then responsible for compiling the response.
current_page?(action: 'edit')
See ActionView::Helpers::UrlHelper#current_page?
Rails also makes the methods controller_path
, controller_name
, action_name
available for use in the view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With