flickr with rails3

rails new flickr_sample
cd flickr_sample

In your gemfile
gem ‘flickraw’

bundle install ~

rails g controller photos

In app/controller/photos_controller.rb

class PhotosController < ApplicationController
require ‘flickraw’

def index

def show
FlickRaw.api_key=”YOUR FLICKR API KEY”
FlickRaw.shared_secret=”YOUR FLICKR SECRET”
info = =>url.split(“/”).last)
@embed_photo[“flickr”]=FlickRaw.url(info) rescue FlickRaw.url_o(info) rescue FlickRaw.url_b(info)
@title = info.title
@square_url = FlickRaw.url_s(info)
@taken = info.dates.taken
@views = info.views
@tags = {|t| t.raw}

In app/views/photos/index.html.erb

<% form_tag(:photo) do %>
<%= label_tag(:url, “Search for:”) %>
<%= text_field_tag(:url) %>
<%= submit_tag(“Enter”) %>
<% end %>

In app/views/photos/show.html.erb

<embed src=”<%=@embed_photo[‘flickr’]%>” width=”375″ height=”225″ /><br/>
<%= “Photo title is #{@title} with #{@views} views” %><br/>
<%= “Tags are #{@tags}” %>

In config/routes.rb

root :to => “photos#index”
match “show” => “photos#show”,:as => :photo

rm public/index.html.erb

rails s

In your browser

About ScratchingRails

Hi,yep I am new to ror ,this blog is for all those who are beginin wit ror
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s