Topic: Yet another RESTful question

I have a Usertype model (which I'm not really going to be using much as I only have one usertype at the moment, but I will have multiple types in future).  A User belongs_to Usertype and Usertype has_many users.  What's the best way for me to update the Usertype?  I don't want to do it in the new/edit User actions because this is where a User will update their own details.  I can't see any RESTful way of doing this - I'm thinking I just need a change_type action in my User Controller.  But I just want to check before I go down this route.

Re: Yet another RESTful question

What's the purpose of your Usertype model?  If it's to label different kinds of users like Admin, Member, etc. then you may want to use a different approach altogether.

Single-Table Inheritance is commonly used for this task:
http://wiki.rubyonrails.org/rails/pages … nheritance

Re: Yet another RESTful question

I have done this through permissions. Simply don't display the usertype field in the new/edit form if the user editing the page isn't an admin. Does that make sense?

Railscasts - Free Ruby on Rails Screencasts

Re: Yet another RESTful question

ryan: I had considered doing it with permissions but I wasn't sure how well it would work/easy it would be.  While I know how to restrict a whole action from being seen by a certain type of user I'm not sure with individual items on a page.  I presume I just need to do an if statement around those bits that I only want an admin to see - but I can foresee this as getting quite a pain if I have lots of things like that.  That's why I was looking at some other method, but I do think the permissions idea is probably the simplest!  Thanks.

Re: Yet another RESTful question

Yep, a simple "if" condition will work. If the condition is complex you can move it into its own method. I think moving the administration functionality into its own action would be more painful than "if" conditions.

Railscasts - Free Ruby on Rails Screencasts