I’m having problems with validation error messages appearing in my app.
In Controller:
def permissions
@roles = Role.find(:all, :order => ‘name’)
end
def new_role
@role = Role.create(params[:role])
if request.post? and @role.save
flash['notice'] = 'Successfully created a new Role'
redirect_to :action => "permissions"
else
flash['notice'] = 'The Role was not created. There was an error
try again’
render :action => ‘permissions’
end
end
Basically I have a permissions page that has a form on it to create new
roles. If the role is created correctly it redirects to the permissions
page and displays the flash. When it fails the display is fine but the
URL now shows “accounts/new_role”. But I am clearly rendering
permissions not new_role. If I change it to “redirect_to” then it
display the “accounts/permissions” page fine but my validation errors do
not display? Anyone shed some light onto what is the correct way please?