# Rails 1.0 blues

**URL:** <https://www.ruby-forum.com/t/rails-1-0-blues/96701>\
**Category:** Ruby\
**Created:** [January 24, 2006, 6:08pm UTC](https://www.ruby-forum.com/t/rails-1-0-blues/96701 "2006-01-24T18:08:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![isamura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@isamura](https://www.ruby-forum.com/u/isamura)\
**Post date:** [January 24, 2006, 6:08pm UTC](https://www.ruby-forum.com/t/rails-1-0-blues/96701/1 "2006-01-24T18:08:23Z")

</div>

I am a Rails nubee but not to web app development. I’ve been pouring  
over  
the docs and tutorials for a week or two. I think have enough knowledge  
to  
start developing, in baby-steps.

At the moment I have a functioning guest-book with the usual CRUD  
operations  
that Rails is so good at. It works well for the single page,  
/slurp/topic.

The problem is reuse. What is the natural Rails way to reuse the  
guest-book  
functionality in other controller pages, for example /book/review.

Does one copy and paste code and templates (and create new table)? I  
hope  
not as this doesn’t sound like a proper approach.

Please say it ain’t so and convince me not to go back… 😉

TIA,

…k

---

<div class="post-metadata">

**Author:** ![isamura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@isamura](https://www.ruby-forum.com/u/isamura)\
**Post date:** [January 24, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/rails-1-0-blues/96701/2 "2006-01-24T18:26:41Z")

</div>

If I am incorrect, someone please correct me, but I believe one of the  
goals of Rails is to be so efficient in use that you begin to forget  
about the holy grail of re-use. If I remember correctly, there is a  
comment on this by DHH while discussing the components feature of RoR.  
In my personal experience I try to use the composed\_of feature of  
ActiveRecord and use generic objects to build “things”. I have also  
found that use of a rcs has helped me in RoR code reuse.

---

<div class="post-metadata">

**Author:** ![isamura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@isamura](https://www.ruby-forum.com/u/isamura)\
**Post date:** [January 24, 2006, 6:14pm UTC](https://www.ruby-forum.com/t/rails-1-0-blues/96701/3 "2006-01-24T18:14:28Z")

</div>

isamura wrote:

> Does one copy and paste code and templates (and create new table)? I hope  
> not as this doesn’t sound like a proper approach.
> 
> Please say it ain’t so and convince me not to go back… 😉
> 
> TIA,
> 
> .k

The models you produce are accessible from all controllers. If you  
create an “Entry” model then you can use it from any controller or  
directly from a view.

For the views, rails uses a system of ‘partials’ for repeated content.  
If you want to have a common layout for guestbook entries you could  
create a file called ‘\_entry.rhtml’ (note the leading underscore).  
Within the same controller you can call “render :partial =\> ‘entry’” to  
render this partial once. To access it from another controller use  
“render :partial =\> ‘entries/entry’” (where ‘entries’ is the directory  
under ./views/ that the partial is found in.)

Note that partials don’t have access to the local variables of the  
original view. You need to pass these in under the option ‘locals’.  
e.g. “render :partial =\> ‘entry’, :locals =\> {:entry =\> @entry}” will  
give the partial a local variable ‘entry’ containing the contents of  
@entry.

If you want to iterate over an array of entries, rendering the partial  
for each one, use “render :partial =\> ‘entry’, :collection =\>  
@entries”. The partial will have the local variable with the same name  
as itself (‘entry’) set to the current entry to render.

I hope this is a decent introduction and isn’t too confusing. I started  
using rails about a month and a half ago and am absolutely loving it.  
The book “Agile Development with Rails” provides a very good  
introduction all the way from the very basics to advanced use of Rails’  
powerful environment. I highly recommend it.

---

<div class="post-metadata">

**Author:** ![isamura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@isamura](https://www.ruby-forum.com/u/isamura)\
**Post date:** [January 24, 2006, 7:18pm UTC](https://www.ruby-forum.com/t/rails-1-0-blues/96701/4 "2006-01-24T19:18:24Z")

</div>

Hi …

I am looking for a mailing list manager in Ruby and I noticed QwikWeb  
(see RAA or [http://qwik.jp](http://qwik.jp)). It looks ideal for my purposes, combining  
a Wiki with a mailing list.

My only problem is that almost all of the documentation and web pages  
are in Japanese, not my strongest language. Has anyone done any work in  
English on this project? If so, care to share?

Many thanks,

–

-mark.

---

<div class="post-metadata">

**Author:** ![isamura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@isamura](https://www.ruby-forum.com/u/isamura)\
**Post date:** [January 25, 2006, 1:31am UTC](https://www.ruby-forum.com/t/rails-1-0-blues/96701/5 "2006-01-25T01:31:00Z")

</div>

If this is a duplicate post, I do appologize…

…k

“Timothy G.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote …  
:  
  
:  
: The models you produce are accessible from all controllers. If you  
: create an “Entry” model then you can use it from any controller or  
: directly from a view.  
:  
Of course…

: For the views, rails uses a system of ‘partials’ for repeated content.  
: If you want to have a common layout for guestbook entries you could  
: create a file called ‘\_entry.rhtml’ (note the leading underscore).  
: Within the same controller you can call “render :partial =\> ‘entry’”  
to  
: render this partial once. To access it from another controller use  
: “render :partial =\> ‘entries/entry’” (where ‘entries’ is the directory  
: under ./views/ that the partial is found in.)  
:  
I was actually using :partials in my attempts. Eventhough it worked ok  
I couldn’t help but feel it doesn’t quite meet my requirements.

Further readings lead me to helpers (again not quite what I want) and  
components (render\_component). BINGO! It seems components is  
what I was after.

: Note that partials don’t have access to the local variables of the  
: original view. You need to pass these in under the option ‘locals’.  
: e.g. “render :partial =\> ‘entry’, :locals =\> {:entry =\> @entry}” will  
: give the partial a local variable ‘entry’ containing the contents of  
: @entry.  
:  
: If you want to iterate over an array of entries, rendering the partial  
: for each one, use “render :partial =\> ‘entry’, :collection =\>  
: @entries”. The partial will have the local variable with the same name  
: as itself (‘entry’) set to the current entry to render.  
:  
: I hope this is a decent introduction and isn’t too confusing. I  
started  
: using rails about a month and a half ago and am absolutely loving it.  
: The book “Agile Development with Rails” provides a very good  
: introduction all the way from the very basics to advanced use of  
Rails’  
: powerful environment. I highly recommend it.  
:  
Clear as mudd … 😉

Seriously, a very decent explanation of render :partial that even  
connect  
the dots.

Thanks Tim,

…k

---

<div class="post-metadata">

**Author:** ![isamura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@isamura](https://www.ruby-forum.com/u/isamura)\
**Post date:** [January 25, 2006, 2:04pm UTC](https://www.ruby-forum.com/t/rails-1-0-blues/96701/6 "2006-01-25T14:04:17Z")

</div>

“Timothy G.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote …  
:  
  
:  
: The models you produce are accessible from all controllers. If you  
: create an “Entry” model then you can use it from any controller or  
: directly from a view.  
:  
Of course…

: For the views, rails uses a system of ‘partials’ for repeated content.  
: If you want to have a common layout for guestbook entries you could  
: create a file called ‘\_entry.rhtml’ (note the leading underscore).  
: Within the same controller you can call “render :partial =\> ‘entry’”  
to  
: render this partial once. To access it from another controller use  
: “render :partial =\> ‘entries/entry’” (where ‘entries’ is the directory  
: under ./views/ that the partial is found in.)  
:  
I was actually using :partials in my attempts. Eventhough it worked ok  
I couldn’t help but feel it doesn’t quite meet my requirements.

Further readings lead me to helpers (again not quite what I want) and  
components (render\_component). BINGO! It seems components is  
what I was after.

: Note that partials don’t have access to the local variables of the  
: original view. You need to pass these in under the option ‘locals’.  
: e.g. “render :partial =\> ‘entry’, :locals =\> {:entry =\> @entry}” will  
: give the partial a local variable ‘entry’ containing the contents of  
: @entry.  
:  
: If you want to iterate over an array of entries, rendering the partial  
: for each one, use “render :partial =\> ‘entry’, :collection =\>  
: @entries”. The partial will have the local variable with the same name  
: as itself (‘entry’) set to the current entry to render.  
:  
: I hope this is a decent introduction and isn’t too confusing. I  
started  
: using rails about a month and a half ago and am absolutely loving it.  
: The book “Agile Development with Rails” provides a very good  
: introduction all the way from the very basics to advanced use of  
Rails’  
: powerful environment. I highly recommend it.  
:  
Clear as mudd … 😉

Seriously, a very decent explanation of render :partial that even  
connect  
the dots.

Thanks Tim,

…k
