Users on my site have their profile page. There, users can setup their data. On edit button press this page become editable.
Now another user can explore other users profiles.
So I wonder here:
- Should I make two controllers
ProfileController/IndexandProfileAsAnotherUserSeeItController/Index. First use profile owner to setup data and another use other users to see those data? - Have just one controller
ProfileController/Indexand based on some parameters decide what data to display (edit buttons, remove profile page items buttons etc.)?
Personally, I would have a single controller =>
AccountsControllerorUsersController. In that I would have anActionMethodcalledDetailswhich lists all the details for a particular user.If my site was StackOverflow, a sample route would be:
http://stackoverflow.com/users/30674/pure-kromewhich translates to
{controller}/details/{id}/{optional anything .. which in this case is a name, for SEO}I would also have an
Editaction methodeg
http://stackoverflow.com/users/edit/30674or
{controller}/{action}/{id}Now, the logic in the
DetailsAction Method would determine what is to be displayed on the view. So, if you want to have an Edit button, the controller action method should figure this out and the view will only display it, if it’s been told to.eg (pseduo code)
and the view will be simple.. like
Things to note :-