welcome

Me

My name is Charles Jackson and I'm a contract/freelance web developer based in Liverpool (UK).

I'm currently avaliable for work as of August 2008 and my primary skillsets are LAMP and Rails. You can view a topical resume here.

contact me

Please feel free to get in touch.

Mobile: +44 (0)781 3854017

Email: Charles AT JacksonCharles.co.uk

Skype: primordial6

MSN: support AT webconfection.com

Twitter: _primordial

Rails Atom Feed

21 days ago

I know there is alot of hype around rails both good and bad with some developers choosing to bad mouth it as "...not robust, flimsy and too easy to bother learning... " but so far I've found it no harder nor easier than most other languages and frameworks I've used. It's the simple pain-in-the-arse functionality this RoR excels in the stuff I'm glad to be rid of such as the creation of an atom feed for my blog posts. Look at this stupidly simple example that I used to create an atom feed for all the posts in my blog.


FILENAME - index.rss.builder


# rss.builder

atom_feed(:schema_date => @posts.last.created_at.year) do |feed|

  feed.title("Jackson Charles")

  feed.updated(@posts.first ? @posts.first.created_at : Time.now.utc)

  @posts.each do |post|

    feed.entry(post) do |entry|

      entry.title(post.title)

      entry.content(post.body, :type => 'html')

      entry.author(post.tag)

    end

  end

end


FILENAME - posts.controller.rb


  def index

    @posts = Post.find(:all, :conditions => ["status = ?", 1], :order => 'created_at desc')

    respond_to do |format|

      format.html # index.html.erb

      format.rss

    end

  end


Then I dropped a suitable link in the header section of my appropiate layout file and it was all done!


<link rel="alternate" type="application/rss+xml" title="RSS" href="http://jacksoncharles.co.uk/posts.rss" />


All done


 

...add comment... ...view more...