No, it's one form with which I update all of my models. The form itself belongs to the subscription model.
The subscription model belongs to the payment and user model and the payment and user model on the other site have one subscription. I'm trying to get a clue how I can solve this but the only thing I found out by now is that I'm not the first one with this problem (how wondering :)) but no solution or at least something that points me in the right direction (ok, updating to Edge Rails is no solution for me right now). Every hint is appreciated. Regards, Stefan On 22 Feb., 04:35, Maurício Linhares <[email protected]> wrote: > You haven`t showed your view code, so i`m assumming that every object > has it`s own "place", so why don't you just add an error_messages_for > every object at the beginning of their part in the form? > > - > Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br) > |http://blog.codevader.com/(en) > > On Fri, Feb 20, 2009 at 10:15 PM, Stefan Frede <[email protected]> wrote: > > > Hi! > > > I have a problem with the presentation of error messages for multiple > > objects. The validation works fine and if errors occure they will all > > be presented, but only for one object at a time. When I submit my form > > the occuring errors will be presented and if I fix them and submit the > > form again the errors for the next form will be presented and so on. > > > I don't know what I have to do to show all errors for all objects at > > once. > > > In my view template I use <%= error_messages_for payment, > > subscription, user %>. > > > This is how my create method looks like: > > > def create > > �...@payment = Payment.new(params[:payment]) > > �...@subscription = Subscription.new(params[:subscription]) > > �...@user = User.new(params[:user]) > > > �...@service = SubscriptionService.new(@subscription, @user, @payment) > > > if @service.save > > flash[:notice] = 'Subscription was successfully created.' > > redirect_to root_url > > else > > render :action => "new" > > end > > end > > > This is how my SubscriptionService looks like: > > > class SubscriptionService > > > attr_reader :payment, :subscription, :user > > > def initialize(subscription, user, payment) > > �...@payment = payment > > �...@user = user > > �...@subscription = subscription > > end > > > def save > > return false unless valid? > > begin > > Subscription.transaction do > > if @payment.new_record? > > �[email protected] = @subscription > > �[email protected]! > > end > > if @user.new_record? > > �[email protected] = @subscription > > �[email protected]! > > end > > �[email protected]! > > true > > end > > rescue > > false > > end > > end > > > def valid? > > �[email protected]? && @subscription.valid? && @user.valid? > > end > > end > > > I think this is pretty basic code and I already found out that the > > presentation has something to do with valid? method in the > > SubscriptionService but as I said I don't know how and where to > > collect all error messages and present them at once. > > > Many thanks in advance. > > > Regards, > > Stefan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

