Rahul Mehta
2010-Apr-04 07:08 UTC
rss feeds from two tables and to come on top the latest created in two tables
hii all
want to generate rss feeds from two tables and to come on top the
latest created in two tables
1st table
create table
CREATE TABLE `content_masters` (
`id` int(11) NOT NULL auto_increment,
`image_path` varchar(255) collate utf8_unicode_ci default NULL,
`content_text` text collate utf8_unicode_ci,
`abstract_text` varchar(700) collate utf8_unicode_ci default NULL,
`title` varchar(255) collate utf8_unicode_ci default NULL,
`color` varchar(255) collate utf8_unicode_ci default NULL,
`parent_id` int(11) default NULL,
`promote` int(11) default ''0'',
`promote_block` varchar(255) collate utf8_unicode_ci default
''N'',
`draft_state` varchar(255) collate utf8_unicode_ci default
''N'',
`order_no_article` int(11) default NULL,
`created_at` datetime default NULL,
`updated_at` datetime default NULL,
`photo_file_name` varchar(255) collate utf8_unicode_ci default NULL,
`photo_content_type` varchar(255) collate utf8_unicode_ci default
NULL,
`photo_file_size` int(11) default NULL,
`photo_updated_at` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8
COLLATE=utf8_unicode_ci
create table
CREATE TABLE `sub_content_masters` (
`id` int(11) NOT NULL auto_increment,
`abstract_text` varchar(700) collate utf8_unicode_ci default NULL,
`title` varchar(255) collate utf8_unicode_ci default NULL,
`image_id` varchar(255) collate utf8_unicode_ci default NULL,
`order_no` int(11) default NULL,
`created_at` datetime default NULL,
`updated_at` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
COLLATE=utf8_unicode_ci
want to join these two table in query
so that i got the latest created , title with abstract_text
------------------------------------------------------------------------------------------------------------------------------------
my xml code
xml.instruct!
xml.rss "version" => "2.0", "xmlns:dc" =>
"http://purl.org/dc/elements/
1.1/" do
xml.channel do
xml.title "Atlantis Software Articles "
xml.link url_for :only_path => false, :controller =>
''articles''
xml.description "Atlantis Software Articles"
@articles.each do |article|
xml.item do
xml.title article.title
xml.link (root_url+article.title.gsub(/
/,''-'').downcase)
xml.description article.content_text
end
end
@subcon.each do |article|
xml.item do
xml.title article.title
xml.description article.abstract_text
end
end
end
end
--------------------------------------------------------------------------------------------------------------------------------------
controller code
def rss
@articles = ContentMaster.find(:all, :order => "id DESC")
@subcon = SubContentMaster.find(:all, :order => "id DESC")
render :layout => false
response.headers["Content-Type"] = "application/xml;
charset=utf-8"
end
pls help..
thanks
rahul
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.