Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #rails 2.02
- # problem is that after setting error message in the listing class... it doesnt show up in the flash in the controller method flash[:error]
- class Desire < ActiveRecord::Base
- attr_accessor :error_message
- has_many :listings
- def after_create
- Listing.create(:desire_id => self.id)
- end
- end
- class Listing < ActiveRecord::Base
- def after_create
- self.desire.error_message = "foo"
- end
- end
- class DesiresController < ApplicationController
- def create
- @desire = Desire.new(params[:desire])
- @desire.user_id = current_user.id
- if @desire.save
- # current_user.desires << @desire
- debugger
- flash[:notice] = 'Desire was successfully created.'
- flash[:error] = @desire.error_message
- redirect_to :action => 'index'
- else
- render :action => 'new'
- end
- end
Add Comment
Please, Sign In to add comment