Created
August 26, 2010 14:37
-
-
Save anonymous/551502 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#EN LA VISTA | |
<% active_assignment = @card.active_assignment %> | |
<% @card.old_employee_id = active_assignment.employee_id if !active_assignment.nil? %> | |
<%= f.select("new_employee_id", @employees.collect{|e| [ e.name + " " + e.last_name, e.id ] }, {:include_blank => true, :selected => @card.old_employee_id}) %> | |
... | |
#EN EL CONTROLADOR | |
if @card.update_attributes(params[:card]) | |
if params[:card][:new_employee_id] != params[:card][:old_employee_id] | |
@card.reassign(params[:card][:new_employee_id]) | |
end | |
format.html { redirect_to(@card, :notice => 'Card was successfully updated.') } | |
format.xml { head :ok } | |
else | |
... | |
#NUEVAS COSAS EN EL MODELO | |
class Card < ActiveRecord::Base | |
... | |
attr_accessor :old_employee_id | |
... | |
def active_assignment() | |
self.card_assignments.all(:conditions=>["active_since < '#{DateTime.now.utc}' and '#{DateTime.now.utc}' < active_until"]).first | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment