Hi guys,
I need help with validations, or to be more exact, what happens after
validations fail.
Here are my AR validations in the model:
class Reviewform < Base
validates :project_number, :subproject_number, :translator,
:reviewer, :no_tus, :allocated_time,
:time_spent, presence: true
end
These work and produce standard error output in the browser, which is
ugly for the end user. I'm struggling with making a nicer error message.
Here's my controller:
class FormNew
def get
@reviewform = Reviewform.new
render :new
end
def post
@reviewform = Reviewform.create(common_attributes)
if @reviewform.errors
render :error
else
end
end
end
I check if there are any errors for the @reviewform and then I want to
render the error view. However, it doesn't work. I get:
Mab::Mixin::Error at /form/new
Tags can only be written within a `mab { }`-block
If I change render with redirect Index it works.
What I'd need to do is if the above validations pass, then create the
form, otherwise stay on the page and let the user now there are errors.
Like the flash in rails. Can it be done in some way?
Thank you.
regards,
seba
_______________________________________________
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list