Topic: Passing static variable from a form
I have a form that I use to allow names in the DB to be updated...this works.
I added a new field in my DB called "updated_by" because I want to know the username of the person the edits the record.
I want to be able to now pass @sessionuser.login which contains the username behind the scenes from the form to my controller without having to ask for it.
I thought I would add it in my edit.rhtml view on the first line as follows but this doesn't work:
<%= start_form_tag :action => 'update', :id => @link, :updated_by => @sessionuser.login %>
<% if @sessionuser.login == "administrator" %>
<%= render :partial => 'formadmin' %>
<% else %>
<%= render :partial => 'form' %>
<% end %>
<%= submit_tag 'Edit' %>
<%= end_form_tag %>
I also tried putting it in my controller under "update" as follows but this doesn't work either:
@link.updated_by = session[:user]
@link = Link.find(params[:id])
flash[:notice] = 'Record was successfully updated'
redirect_to :action => 'indexadmin', :id => @listall
render :action => 'edit'
Any help would really be appreciated....thanks.