SEO on Ruby on Rails
25 Jun 2009
Knowledge
Here are some rails-way tips on SEO. Please share me your tips because there is always more than one way to do something when it comes to Ruby.
Continue reading...Here are some rails-way tips on SEO. Please share me your tips because there is always more than one way to do something when it comes to Ruby.
Continue reading...Cucumber allow us to describe behavior in plain text. Because the text is written in a business-readable domain-specific language, beside serves as automated tests and development-aid, it also can be used as documentation. In this post we’re going to create a Rails application from scratch, and use Cucumber to define its behaviour.
Continue reading...
def see_my_myspaceuserid
@consumer = OAuth::Consumer.new('your OAuth Consumer Key', 'your OAuth Consumer Secret', {:site => 'http://api.myspace.com', :http_method => :get, :request_token_path => '/request_token', :authorize_path => '/authorize',:access_token_path=>'/access_token'})
@request_token = @consumer.get_request_token
redirect_to @request_token.authorize_url + 'oauth_callback=display_myspace_user_id'
end
So once the user clicks on the link, he'll be redirected to myspace to login there. After he logs in there, he'll be redirected back to your site. Let's say the callback url is called 'display_myspace_user_id', so here's what it'll look like:
def display_myspace_user_id
# You can save the @request_token from action 'see_my_myspaceuserid' and use it here
response = @request_token.get_access_token.get('/v1/user.xml')
# Now use REXML::Document to parse response.body, and you'll get the user_id !
end
How do I know that the parameter to access_token is '/v1/user.xml' ?
Read here: http://developer.myspace.com/community/RestfulAPIs/resources.aspx
That's it. You can use the access_token to do all sorts of REST API calls to Myspace now!
I hope this helps.
Example.class_eval do after_save :somemethod def somemethod end endNote that you dont wanna put that code under vendor/plugins/ . Instead, put it under a place where it's executed everytime.