Created
March 9, 2010 10:46
-
-
Save ignacy/326476 to your computer and use it in GitHub Desktop.
This file contains 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
# KOntroller: | |
class AuctionsController | |
# .... | |
def create | |
@auction = params[:auction][:type].constantize.new(params[:auction].merge(:calendar_validation => true, :private => false)) | |
if @auction.save | |
redirect_to auction_products_path( @auction ) | |
else | |
flash.now[:error] = t('errors_on_page') | |
render :action => :new | |
end | |
end | |
#.... | |
end | |
# model | |
class Auction < ActiveRecord::Base | |
#.... | |
before_create :set_begin_state | |
before_create :build_default_product_groups | |
#.... | |
end | |
# Tak jak widzisz save jest robione w kontrollerze, a w modelu sa ewentulanie walidacjhe (before...) albo jakies | |
# inne metody pomocnicze nie pasaujace do CRUD... np: pobierz wszystkich licytujacych | |
def bidders | |
email_offer = offers.notdrafts.collect { |o| o.company.email } | |
email_inv = invitations.collect { |i| i.email} | |
mails = (email_offer + email_inv).uniq | |
returning Hash.new do |tab| | |
mails.each do |mail| | |
user = User.find_by_email(mail) | |
user.present? ? tab[mail] = user.company : tab[mail] = nil | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment