Hi all, I’ve the following doubt.
I’ve this controller methods:
def set_elaborator
@entry = Entry.find(params[:id])
@entry.geomatics_elaboration_id = current_user.id
if @entry.save!
redirect_to(@entry, :notice => ‘Elaborator setted successfully’)
end
end
def set_reviewer
@entry = Entry.find(params[:id])
@entry.geomatics_checker_id = current_user.id
if @entry.save!
redirect_to(@entry, :notice => ‘Elaborator setted successfully’)
end
end
So, I want to add a link in the show view, like this:
<%= t(‘entries.fields.geomatics_elaboration’) %>:
<% if @entry.geomatics_elaboration_id.nil? and current_user.geomatics %>
<%= link_to entry, :confirm => ‘Are you sure?’, :method => :set_elaborator do %>
<% end %>
<% elsif @entry.geomatics_elaboration_id.nil? and not current_user.geomatics %>
<%= t(‘entries.messages.not_assigned_yet’) %>
<% else %>
<%= User.find(@entry.geomatics_elaboration_id).fullname %>
<% end %>
<%= t(‘entries.fields.geomatics_review’) %>:
<% if @entry.geomatics_checker_id.nil? and current_user.geomatics %>
<%= link_to @entry, :confirm => ‘Are you sure?’, :method => :set_reviewer do %>
<% end %>
<% elsif @entry.geomatics_checker_id.nil? and not current_user.geomatics %>
<%= t(‘entries.messages.not_assigned_yet’) %>
<% else %>
<%= User.find(@entry.geomatics_checker_id).fullname %>
<% end %>
I want to, when I click the link update the @entry and load the show template with the changes…
Any suggestion?
Regards,