To all that have helped out thank you I do have what i wanted to
accomplished though it may not be super efficient it does what i need
with no repeats from my tests here is what i have done.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index.html.erb
<% @contents.each do |content| %>
<div id="link"><a href="<%=h content.cont_url %>" title = "<%=h
content.cont_url %>"><%=h(truncate(content.cont_url , 20)) %></a></div>
<div id="comment"><%=h content.comments %></div>
<% end %>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
content_controller.rb
def index
@contents = Content.find_content
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @contents }
end
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
content.rb
def self.find_content
find(:all, :limit => '3', :order => 'rand()')
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you have any questions or improvements or comments please let me know
thank you..
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.