This discussion is a continuation of how to restrict the creation of a
new record if the logged-in already has a record. Thanks Pradeep for
the reply, but Sergio had advised much easier and shorter way to
implement that using def create_authorized?

def create_authorized?
    Employee.count(:conditions => {:employee_id =>
current_user.employee_id}) == 0
end

This works when an employee is logging in and he is already having a
record.

Now consider the situation. He is logging in and he has not created
any record yet. So the "Create New" button is visible. He creates the
record. But after saving the record, now the "Create New" button is
still visible even though he has a record. This is because the page is
not rendered from the beginning for the def create_authorized? to get
called.

How to make this employee restrict the creation of another record as
soon as he has successfully created the first one?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to