# Rails 2.1 Generating a RESTful controller?

**URL:** <https://www.ruby-forum.com/t/rails-2-1-generating-a-restful-controller/141081>\
**Category:** Rails\
**Created:** [June 21, 2008, 6:51pm UTC](https://www.ruby-forum.com/t/rails-2-1-generating-a-restful-controller/141081 "2008-06-21T18:51:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [June 21, 2008, 6:51pm UTC](https://www.ruby-forum.com/t/rails-2-1-generating-a-restful-controller/141081/1 "2008-06-21T18:51:42Z")

</div>

I’ve recently made the upgrade to rails 2 and it seems to really  
encourage restful design now.  
So I’ve been looking into that and I am getting the hang of it, but it  
really bothers me to have to manually setup the REST actions in the  
controller.

It seems like there should be some way to script/generate restful  
controller or something for example:  
script/generate controller posts

would be smart enough to go ahead and include actions (index, show, new,  
create, edit, update and delete) and also go ahead and fill them out  
smartly based on the controller name, and knowing that I want a restful  
controller and that I have a model with the same name.

so it would already have:

def index  
@posts = Post.find(:all)  
end

def new  
@post = Post.new  
end

etc.

Is there a way to do this?

If not, is this the sort of thing people would usually write a plugin  
for? Maybe I could look into writing a plugin for it.

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [June 21, 2008, 6:54pm UTC](https://www.ruby-forum.com/t/rails-2-1-generating-a-restful-controller/141081/2 "2008-06-21T18:54:51Z")

</div>

On 21 Jun 2008, at 17:51, Chris G. wrote:

> I’ve recently made the upgrade to rails 2 and it seems to really  
> encourage restful design now.  
> So I’ve been looking into that and I am getting the hang of it, but it  
> really bothers me to have to manually setup the REST actions in the  
> controller.
> 
> It seems like there should be some way to script/generate restful  
> controller or something for example:  
> script/generate controller posts

The scaffold generator in rails 2 and above generates a restful  
scaffold.

Fred

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [June 21, 2008, 6:58pm UTC](https://www.ruby-forum.com/t/rails-2-1-generating-a-restful-controller/141081/3 "2008-06-21T18:58:34Z")

</div>

Thanks, I wondered about that, I haven’t generated scaffold since I was  
first using rails a couple of years ago.

Thanks for the quick reply.  
Chris
