-
-
Save cachafla/551529 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 | |
<%= hidden_field_tag(:old_employee_id, @old_employee_id) %> | |
<%= f.select("new_employee_id", @employees.collect{|e| [ e.name + " " + e.last_name, e.id ] }, {:include_blank => true, :selected => @old_employee_id}) %> | |
... | |
#EN EL CONTROLADOR | |
# en edit | |
@card = Card.find(params[:id]) | |
... | |
... | |
active_assignment = @card.active_assignment | |
@old_employee_id = active_assignment.employee_id if !active_assignment.nil? | |
# en update | |
if @card.update_attributes(params[:card]) | |
if params[:card][:new_employee_id] != params[: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 | |
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