Jquery Full Calendar with Ruby on Rails
Contrary to popular belief, working on a client project gives us a generous margin of creativity and explore innovative solutions. Take the example of a recent project I was working on. The client required a collaboration-based calendar module for their application similar to Google Calendar. Initially we started developing it from scratch , but then, we found an awesome Jquery plugin.
“FullCalendar” provides a full-sized, drag & drop calendar. It uses AJAX to fetch events on-the-fly for each month. It also supports an intuitive interface to manage events that spans over multiple days or weeks. It is visually customizable and exposes hooks for user-triggered events (like clicking or dragging an event).
I decided to give it a try and utilize its hooks for user triggered events within our Rails application. This small effort resulted in a barebone Rails app that might provide a good base for your project which require calendar, scheduling or appointment features. I called it fullcalendar_rails and it is now available on github with a working demo at http://fullcalendar.vinsol.com.
Feel free to give your valuable feedback. I hope you will find this useful.
Update: On popular demand, I have added recurring events functionality with daily, weekly and monthly frequencies. It also allows for exceptions to recurring events including delete and edit features.
Integrating Yahoo! BOSS with your ruby on rails application
What is Yahoo! BOSS? Yahoo developer website cites it as:
“Yahoo! Search BOSS (Build your Own Search Service) is an initiative in Yahoo! Search to open up Yahoo!’s search infrastructure and enable third parties to build revolutionary search products leveraging their own data, content, technology, social graph, or other assets. This release includes Web, News, and Image Search as well as Spelling Suggestions.”
Some of the possible implementation of Yahoo! Boss may be finding related posts for your article, suggested tag/category for an article/query, correcting misspelled words by providing suggestions, fetching latest news on a topic dynamically, search over delicious tags, customized language search. Some of these have been tried and successfully implemented. An example is the TechCrunch’s Search Engine.
Here is a concise guide on how to use this new service in your next rails application.
Obtain API key
Get an application key from http://developer.yahoo.com/search/boss/.
Install BOSSMan Gem
BOSSMan is a gem for interaction with the Yahoo BOSS web service written by John Pignata. Install it using the following commands:
gem install gemcutter gem tumble gem install bossman
Usage
Put this in your environment.rb
require 'bossman' include BOSSMan BOSSMan.application_id = <Your Application ID>
Web Search
Use the following code to execute search over the web:
boss = Search.web("Apple Pie", { :count => 2, :filter => "-hate" })
puts "Number of results: #{boss.totalhits}"
boss.results.each do |result|
puts "#{result.title}"
puts "#{result.dispurl}"
puts "#{result.abstract}"
end
# => Number of results: 2618888
# => <b>Apple</b> <b>pie</b> - Wikipedia, the free encyclopedia
# => <b>en.wikipedia.org</b>/wiki/<wbr><b>Apple</b>_<b>pie</b>
# => English <b>apple</b> <b>pie</b> recipes go back to the time of Chaucer. <b>...</b> The basis of Dutch <b>apple</b> <b>pie</b> is a crust on the bottom and around the edges. <b>...</b>
boss = Search.web("Moon", { :count => 10, :type => "nonhtml,-pdf" })
boss.results.each do |result|
puts "#{result.title}"
puts "#{result.dispurl}"
puts "#{result.abstract}"
end
# => BACKGROUND:
# => www.<b>radford.edu</b>/~rusmart/<wbr><b>moon</b>.doc
# => We noticed was that one of the scan lines took longer to scan the <b>moon</b> then any other. This occurred toward the middle of the <b>moon</b>. <b>...</b>
boss = Search.web("Star", { :sites => "wwe.com", :style=>'raw' })
boss.results.each do |result|
puts "#{result.title}"
puts "#{result.dispurl}"
puts "#{result.abstract}"
end
# => John Cena - WWE: Raw
# => www.<b>wwe.com</b>/super<b>star</b>s/raw/<wbr>johncena
# => Official profile from WWE for the professional wrestler John Cena, who has been training since he was 15. Features lots of photos and video clips, including John ...
Apart from universal arguments mentioned at the end of this document, the following arguments can also be used:
| Parameters | Values/Description |
|---|---|
:filter |
Filter out adult or hate content Syntax: :filter => "-hate, -porn"
|
:type |
Specifies document formats (pdf, msoffice,etc) |
| :view | Syntax: :view => "view1,view2", etc
|
| :abstract | :abstract => "long" will retrieve and display an abstract of a web document up to 300 characters. This expanded abstract provides the requestor with a larger piece of information to work from in a web search query. The default for abstract is an abbreviated description. |
Click here to view list of response fields returned by web search.
Images Search
For searching images on web, use the following code:
boss = Search.images("snow hills", { :dimensions => "large" })
boss.results.each do |result|
puts "#{result.url}: #{result.abstract}"
end
# => http://www.amanita-photolibrary.co.uk/photo_library/BI_habitats/gb96_chiltern_hills_from_ivinghoe_snow_std.jpg: Copyright © 2004 Chiltern hills east from near Ivinghoe snow habitats landscapes British Isles
Click here for list of additional arguments that can be provided with image search.
Click here to view list of response fields returned by image search.
News Search
Yahoo! BOSS also provides news search capabilties.
boss = BOSSMan::Search.news("free shipping", { :age => "1d-2w", :orderby => "date", :count => 1})
boss.results.each do |result|
puts "#{result.title} [from #{result.source}]"
puts "#{result.abstract}"
end
# => Wal-Mart announces weekly price cuts for holidays [from USA Today]
# => Wal-Mart said it will cut prices this holiday season for a week at a time on thousands of items, from bananas to board games. The first group of cuts hit Wednesday.
Click here for list of additional arguments that can be provided with news search.
Click here to view list of response fields returned by news search.
Spelling Search
Correct your misspelled words using its spelling suggestion feature:
boss = BOSSMan::Search.spelling("acknowlegment") puts boss.suggestion # => acknowledgment
Site Explorer
You can also search for the pages from other sites linking into your site pages.
links = Search.se_inlink("http://mail.yahoo.com", :count => 2)
links.results.map { |result| p result.url }
# => http://www.aol.com/
# => http://groups.yahoo.com/
For displays a list of all pages belonging to a domain in the Yahoo! index, use se_pagedata method provided.
links = Search.se_pagedata("twitter.com", :count => 1)
links.results.map { |result| p "#{result.url} - #{result.abstract}" }
# => http://twitter.com/ - Use Twitter to send status updates (tweets) through your cell phone, instant messenger, or via the Web, and notify friends and followers of the little things <b>...</b>
Universal Arguments for Web, Images and News
Following is the list of most commonly used arguments with web, image and news search. For more comprehensive list click here
| Argument | Options/Details |
|---|---|
:start |
Ordinal position of first result. First position is 0. Default sets start to 0. |
:count |
Total number of results to return. Maximum value is 50. Default sets count to 10. |
:format |
The data format of the response. Value can be set to either "xml" or "json". Default sets format to "json". |
:callback |
The name of the callback function to wrap the result. Parameter is valid only if format is set to "json". No default value exists. |
:sites |
Restrict BOSS search results to a set of pre-defined sites. Multiple sites must be comma separated. Example: (:sites => "abc.com,cnn.com"). The Images service does not yet support multiple sites. |
:view |
Retrieve additional search data provided by the respective BOSS service. Please see individual chapters to see what view options are available. |
:style |
By default for web search result titles and abstracts contain bold HTML tags around the search term. Use :style => "raw" to remove the bold tags around the search terms in titles and abstracts. |
Ruby on Rails Caching And JavaScript Techniques
Cross posted from darthsid
While implementing caching in a recent rails project I came across some typical caching issues. In a lot of pages the content is same for all users but certain components in them have user specific actions. As an example, I have a page listing all public messages that users have posted(similar to the public timeline in twitter) but actions on those messages are user specific(eg: only owner or admin can delete a message). Also, most of these actions use ajax and the rails authenticity token in them also gets cached resulting in subsequent failures if the session changes. Another issue was that the timestamps in most pages is fuzzy and they become irrelevant if a page gets cached for too long. I could have created separate caches for each user but if the user base really grows managing the caches would become a nightmare and that would still not solve the authenticity token and the timestamp problem. The simplest solution was to use JavaScript, more specifically jQuery.
Read more
Git Work Flow For Ruby on Rails Developers
Cross posted from darthsid
This is my very first blog post and so I though it should be about a tool that is indispensable for me – Git. I started using git about 10 months ago and looking back I can’t imagine how I managed to get work done without it. The purpose of this post however is not to sing git’s praises, there are lots of good articles on the web that do so much better than I ever could. Instead, I wish to share the work-flow I use on my projects. I developed this work-flow by trial and error over the months and is currently the most efficient and productive approach I can think of. If any experienced git users happen to stumble upon this post, please do provide suggestions/alternatives to help me improve my process.
The project I am currently working on requires me to maintain two parallel deployment branches. One is a “production branch” which is deployed on the live server and the other is a “development branch” which is deployed on a staging server. All enhancements and feature additions are done in the “development branch” and the only changes made in the “production branch” are production bug fixes that need urgent attention. Once the “development branch” is deemed stable it is merged into “production branch” and deployed.
Read more
How to install Ruby on Rails on almost any popular Operating System?
My friends who are starting with Rails usually ask – how to install rails on “operating system of their choice”? And I end up searching for best tutorial for every operating system and sharing that link. On a lazy tuesday morning, I decided to collect all the good links and share it here. If you think I am missing any OS or a great tutorial, suggest the link. Thanks.
Following the DRY (don’t repeat yourself) principle, I am just putting the links of best tutorial (in my opinion) for every operating system.











Working with Vinsol has been one of the most rewarding and productive collaborations I've ever had in the technology industry. Manik is an intelligent and honest engineer with a great faculty for open and clear communication, and his team include some of the swiftest and keenest developers I've ever had the pleasure to work with. They're great value for money, excellent people who are a joy to know and interact with, and above all they really know their stuff