Hi,
I''m new at this, how do I send the errors that one would get from a
standard ruby scaffold generator on a form that is attempted to POST
incorrectly? With all the beautiful formatting etc...
Right now I have this:
  # POST /environments
  # POST /environments.xml
  def create
    @project = Project.find(params[:project_id])
    # @environment = Environment.new(params[:environment])
    @environment = @project.environments.create(params[:environment])
    if @environment.save
      redirect_to project_path(@project), :notice =>
''Saved''
    else
      redirect_to project_path(@project), :notice =>
''Error''
    end
And it works, but I only get what I define: "Error", whereas I would
like to get the explicit errors that the validators are catching...
something like: (does not work)
  # POST /environments
  # POST /environments.xml
  def create
    @project = Project.find(params[:project_id])
    # @environment = Environment.new(params[:environment])
    @environment = @project.environments.create(params[:environment])
    if @environment.save
      redirect_to project_path(@project), :notice =>
''Saved''
    else
      rescue ActiveRecord::RecordInvalid => invalid
         @error = invalid.record.errors
        end
      redirect_to project_path(@project), :notice => @error
    end
Any suggestions?
-- 
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.