51224bdd17878b3b19e8987e9bb336a2

Hello,
- Let me explain the scenario. I am creating a plugin which has a requirement to put a
following partial line in every layout file (after end of </html> tag).
<%= render :partial=>'bug/bug_page' %>

- Now I am doing that manually by opening every layout file and pasting that code.

- Is there any other way to do that and also can I Refactor it in order to I don't want to put in every layout file.

- I just want that every page should get rendered by 'bug_page' partial file.

- Also I am rendering that outside the end of </html> tag because I don't want to get my css messed with application css.

application.rhtml

1
2
3
4
5
6
7
8
9
10
11
12
13
<html>
   <head><title>Ruby</title></head>
      <body>

         <p>
            <%= yield %>
        </p>

      </body>
 </html>

<%= render :partial=>'bug/bug_page'  %>

Refactorings

No refactoring yet !

Fb1fc6f2eccd067a19b298d89235bfe0

rupert

July 10, 2008, July 10, 2008 08:16, permalink

No rating. Login to rate!

Not a refactoring as such, but you might want to look at the rails-footnotes plugin for inspiration as it sounds like you're wanting to do something very much along the same sort of lines:

http://github.com/drnic/rails-footnotes/tree/master

F288a8afe5302a16a366d5e9d34f2fec

Joe Grossberg

July 10, 2008, July 10, 2008 13:21, permalink

No rating. Login to rate!

Intial thoughts:

* How many layout files do you have?

* Instead of putting the bug_page partial outside the html tags (yuck!), why don't you just enclose it in a div tag and use more specific CSS to make sure there's no conflict, e.g. (see code sample)

1
2
div#bug_page { background: #000; font-family: courier; }
div#bug_page span.error { color: #f00; }
51224bdd17878b3b19e8987e9bb336a2

DG

July 10, 2008, July 10, 2008 13:53, permalink

No rating. Login to rate!

Hi Joe,

* Number of layouts file will differ from application to application.

* about 2nd thought I will try to implement it.

Thanks :)

51224bdd17878b3b19e8987e9bb336a2

DG

July 14, 2008, July 14, 2008 13:51, permalink

No rating. Login to rate!

Hello rupert
Thanks for your plugin suggestion. :)

Your refactoring





Format Copy from initial code

or Cancel