Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create
- @client = Client.new(params[:client])
- respond_to do |format|
- if @client.save
- # Add purchase
- @sell = Purchase.new
- @sell.client_id = @client.id
- @sell.date = params[:date]
- # Fill another fields
- if @sell.save
- # Do another stuff...
- else
- format.html { render :action => "new" }
- format.xml { render :xml => @client.errors, :status => :unprocessable_entity }
- end
- flash[:notice] = 'You have a new client!'
- format.html { redirect_to(:action => :show, :id => @evento.id) }
- format.xml { render :xml => @client, :status => :created, :location => @client }
- else
- format.html { render :action => "new" }
- format.xml { render :xml => @evento.client, :status => :unprocessable_entity }
- end
- end
- end
- belongs_to :client
- validates_format_of :date, :with => /^20[0-9]{2}[-][0-9]{2}[-][0-9]{2}$/, :message => 'not valid'
- validates_presence_of :date
- Client.purchases.empty?
- Client.purchases.size,
- Client.purchases
- Client.purchases<<(purchase)
- Client.purchases.delete(purchase)
- Client.purchases.find(purchases_id)
- Client.purchases.find_all(conditions)
- Client.purchases.build
- Client.purchases.create
Add Comment
Please, Sign In to add comment