# How to append some action into already available controller?

**URL:** <https://www.ruby-forum.com/t/how-to-append-some-action-into-already-available-controller/121818>\
**Category:** Rails\
**Created:** [December 1, 2007, 10:10am UTC](https://www.ruby-forum.com/t/how-to-append-some-action-into-already-available-controller/121818 "2007-12-01T10:10:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [December 1, 2007, 10:10am UTC](https://www.ruby-forum.com/t/how-to-append-some-action-into-already-available-controller/121818/1 "2007-12-01T10:10:26Z")

</div>

how to append some action into already available controller with  
corresponding views (\*.rhtml) .for example

ruby/script generate controller admin action1 action2…

here admin is already available controller with some action  
now ,what i want is the new actions(action1 action2…) should be  
append  
in admin\_controller.rb and corresponding _.rhtml files  
(action1.rhtml,action2.rhtml…) should be created in app/views/admin/_.

any idea ?

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [December 1, 2007, 12:38pm UTC](https://www.ruby-forum.com/t/how-to-append-some-action-into-already-available-controller/121818/2 "2007-12-01T12:38:13Z")

</div>

On Dec 1, 9:10 am, Pokkai D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> how to append some action into already available controller with  
> corresponding views (\*.rhtml) .for example

What’s wrong with just creating those files/methods by hand ?

Fred

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [December 2, 2007, 6:34am UTC](https://www.ruby-forum.com/t/how-to-append-some-action-into-already-available-controller/121818/3 "2007-12-02T06:34:04Z")

</div>

Frederick C. wrote:

> On Dec 1, 9:10 am, Pokkai D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > how to append some action into already available controller with  
> > corresponding views (\*.rhtml) .for example
> 
> What’s wrong with just creating those files/methods by hand ?
> 
> Fred

i thing the main advanstage in Rails framework compare than others is  
very speed and easy implementation.

actually in some situation i want to create more than one public  
definition(method) in an existing controller .

in my projects there are lots of controllers (more than 300)

for example if i want to create 5 methods with corresponding views in a  
controller than ,if i do like this (ofcourse below is wrong) than my  
speed is 5 to 10 times fater than manual creating…

> ruby script/generate controller [-append] contro met1 met2 met3 met4 met5

and one thing i ask ,why the rails developers should not add this append  
capability in controller generator ?

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [December 2, 2007, 11:42am UTC](https://www.ruby-forum.com/t/how-to-append-some-action-into-already-available-controller/121818/4 "2007-12-02T11:42:09Z")

</div>

On 2 Dec 2007, at 05:34, Pokkai D. wrote:

> > Fred  
> > in a  
> > controller than ,if i do like this (ofcourse below is wrong) than my  
> > speed is 5 to 10 times fater than manual creating…
> 
> > ruby script/generate controller [-append] contro met1 met2 met3  
> > met4 met5

While script/generate controller is a useful starting point  
(especially when you’re not quite sure what the naming conventions  
are, what files go where etc…) in my experience unless the methods  
and views were completely empty the bulk of the effort is in writing  
them and the time spent actually creating the files is rather  
negligible.

> and one thing i ask ,why the rails developers should not add this  
> append  
> capability in controller generator ?

The generators in general tend to create new files rather than edit  
them. Off the top of my head I’d say that’s because it’s a lot easier  
to add things then it is to edit existing things. That said if you can  
find a way to make this all work nicely then you can always submit a  
patch.

Fred
