Hi People,
I’m pretty new to rails so please bear with me on this.
I’m wanting to pull a text file into my rhtml page to use as the header
part of my site. I know I can use layouts but it isn’t pratical for my
problem as there could be hundreds of user made headers.
So there are two ways I can see this happening. One is to store the
location of the file in the database and use that with some sort of ruby
html include tag in the html.
The second is to some how pull the header text from the file into the
model and then output it to the page.
So my question is which of these is the “rails”
way to do this and
how would each of these ideas work in code as I dont have a clue.
hope I’ve made sense
cheers
Tony
On 1/15/08, Mathew M. [email protected] wrote:
I’m wanting to pull a text file into my rhtml page to use as the header
part of my site. I know I can use layouts but it isn’t pratical for my
problem as there could be hundreds of user made headers.
Do you know about render?
<%= render :partial => ‘some_dir/some_header’ %>
http://api.rubyonrails.com/classes/ActionController/Base.html#M000452
–
Greg D.
http://destiney.com/
Ahh I didn’t you could use a partial like that doh!
So is that the best way…there is no way to pull the directory contents
into a property in the model?
On 1/15/08, Mathew M. [email protected] wrote:
Ahh I didn’t you could use a partial like that doh!
So is that the best way…
Compared to what other way?
there is no way to pull the directory contents
into a property in the model?
Sure. I would use Dir.glob.
http://www.ruby-doc.org/core/classes/Dir.html#M002347
–
Greg D.
http://destiney.com/