"Library Management Gets an Update in Rails 3"

Rails 3 revolutionizes gem dependency management by including a new library called Bundler. This new system supersedes the old config.gem system that was built in to Rails 2. It provides all of the functionality of that system and a lot more — now you can be confident that the gems your application depends on will be the same on every developer’s machine as well as every application server.


This week, we’ve got a screencast showing how you would work with gems in Rails 3, and a post describing the most common features of the Bundler in more detail. Both should be suitable for those who have never used Bundler before, but we assume at least a passing knowledge of Rubygems.


Specifying Dependencies


In Rails 3, you list all of the gems that your application requires, along with any version requirements you might have in a Gemfile. The rails command creates a default Gemfile for you when you generate a new empty Rails application. The default Gemfile includes just two gems: Rails itself, and the default database driver, the sqlite3-ruby gem.


If your application requires other gems, you can edit the Gemfile to list them:


adding gems

gem "nokogiri"
gem "will_paginate", "3.0.pre"


As you can see, you can request specific versions of a given gem by adding the version number after the name.


Once you have set up your Gemfile, run the command bundle install to set up all of the gems in your bundle for use with your application. If any of the gems aren’t installed, Bundler will automatically download and install them.


When Rails loads, it will automatically require each of the gems listed in your Gemfile, using the same name as the gem. If the file Rails should require differs from the gem name (for example, sqlite3-ruby is required as “sqlite3”), you should specify the correct name in the Gemfile like this:


custom require

gem "sqlite3-ruby", :require => "sqlite3"


Environment Groups

While you’re developing and testing your Rails application, you may find that there are some gems that you only want to load in certain environments. If there are gems that you only want to load while you are developing your application (like ruby-debug or rack-bug, perhaps), you can specify that in your Gemfile:

groups


group :development do
  gem "ruby-debug"
  gem "rack-bug"
end


You can specify gems that should only load in any of the Rails environments, which includes :test, :development, and :production in a default application. If you have a gem that should be in more than one group, you can either put it in each group block, or you can specify multiple groups on the gem line itself, like


gem “ruby-debug”, :group => [:test, :development].


You can avoid installing certain groups of gems if they will not compile. For example, some Rails applications use PostgreSQL in production, and sometimes getting the pg gem to compile can be hard. To exclude the production and test groups, you would run bundle install –without production test.


Snapshotting


You can take a snapshot of the exact versions of every gem used by your application with the bundle lock command. When you run bundle lock, it will create a file named Gemfile.lock in the root of your application. That file stores the snapshot, including the names and versions of every gem.


You should check this file in to your version control, so that everyone who checks the code out will have the exact same gems. When you run bundle install on an application that has a snapshot, it will install the exact same versions of every gem (including all dependencies and dependencies’ depencencies) that the application was using when you ran bundle lock. This is a good way to ensure that all development and production machines are running the exact same versions of every gem that your application uses.


Deploying to a server


When you are ready to deploy your Rails application to a server, commit both the Gemfile and Gemfile.lock files to your source control. Then, as part of your deploy process, run bundle install before you start your application servers. All of the gems your application depends on will be installed and configured, and your application will be running in production on the exact same gems and versions that you used in development. It’s that easy.


Advanced uses of Bundler


In order to develop and deploy your Rails application, you don’t need to know more than this article already covered. However, Bundler comes with several advanced features that can be very useful under specific circumstances. If you are interested in learning about some of the more advanced capabilities, they are described below.


Advanced: Git dependencies


While you should always use gems that have been released to Rubyforge if you can, sometimes there is a fix that you absolutely need that is only available in the gem’s git repository. In this case, you can use the :git option to specify a git repository as the source for a specific gem. Gems that come from git repositories participate in dependency resolution exactly like regular gems, and their dependencies will be installed if needed.


When you are using the :git option, you can also specify a :branch, :tag, or :ref option to get the gem from a specific git checkout, like so:


git gems

gem "devise",
  :git => "git://github.com/plataformatec/devise.git",
  :branch => "v1.0"


If you use the :tag or :ref option, your git gem will always use that commit, and will never be updated. However, if you use the :branch option (or don’t supply any of the three checkout options), the bundle install command will update the git gem to the latest revision of the given (or master) branch.


C extensions that are specified in the .gemspec file inside the repository will be compiled and installed. Executables in the .gemspec will be installed for use via bundle exec executable.


If the git repository that you supply has a .gemspec file in it, you don’t need to put a version number on the gem line in the Gemfile. However, if there is no .gemspec file, you will need to specify a version so that bundler can generate a .gemspec file that uses default gem conventions.


Advanced: Packaging


Occasionally, the machines you deploy your application to are not able to connect to internet servers, including the Rubygems server. (Blocking outgoing connections from application servers is a somewhat common approach to security.) In that case, you will need to package up the .gem files for all the gems your application needs to run with the bundle package command.


Once you have run the command, all the .gem files will be deposited into the vendor/cache/ directory. Add those files to git and commit them, and on your next deploy, bundle install will simply use those gems instead of looking for them on rubygems.org.


Advanced: Installing to vendor


If you develop on the same architecture that you deploy onto, it is even possible to fully install every gem into your application directory to be checked in to source control. The command to do this is bundle install vendor. After running it, you can check the entire vendor/ directory in to your source control, and bundle install will no longer install anything.


However, this is not a recommended option. It can save installation time, but lead to problems if another developer (or another server you eventually deploy onto) needs to compile native extensions for a different platform or architecture.


More Advanced Features


Bundler supports a number of other use-cases through features not described here. Its full feature-set is described on its official web site


Wrapping up


As you can see, gem dependency management with Rails 3 is simple, yet effective. The bundler adds many new capabilities and features, while at the same time solving the gem conflict issues that Rails 2’s config.gem could suffer from. If you have feedback, need help, or just want to chat about bundler, visit the IRC channel #bundler on Freenode.

"Library Management Gets an Update in Rails 3"

"Mass-assigning protected attributes in Rails"

Rails has a great feature called protected attributes which you can set like this:



class User < ActiveRecord:Base
  attr_protected :account_id
end


Or you can use the inverted versions (which I prefer) where you set which attributes are accessible, like this:



attr_accessible :name, :email


What this does is that it tells Rails which attributes can be used in mass-assignment like this:



User.create(:name => "Piyush", :email => "mba.piyushgupta@gmail.com")


or what’s used more:



User.create(params[:user])


Then some malicious hacker cannot use mass-assignment to manually set the account_id.


If you try to assign to protected attributes you’ll get the following warning:



WARNING: Can't mass-assign these protected attributes: account_id


But the problem is: What if I’m no hacker, but I should have unlimited access, for example as an administrator? Then I can’t mass-assign to any protected attributes. Then I’d need to do something like this:



u = User.new(params[:user])
u.account_id = params[:user][:account_id]


Not very pretty.


What I’ve done is that I’ve created an extension to some of the methods taking mass-assignment and added an optional parameter calledguard_protected_attributes which has a default value of true.


Example:



# config/initializers/unprotected_attributes.rb
class ActiveRecord::Base
  def update_attributes_with_unprotected(attributes, guard_protected_attributes = true)
    send :attributes=, attributes, guard_protected_attributes
    save
  end
  alias_method_chain :update_attributes, :unprotected
end


We can do this because the native ActiveRecord::Base#attributes= can also be called with guard_unprotected_attributes.


Now you can call update_attributes like this:



user = User.find(3)
user.update_attributes(params[:user], false)


and it will also assign the protected attributes.


I have made extensions to create, new, update_attributes, andupdate_attributes!.


The ugly part, however, is that to make it work, I had to copy the functions in their entirety which could potentially mean that if you use it on a Rails version other than exactly 2.3.8 it might not work. Sorry for that.

"Mass-assigning protected attributes in Rails"

"Ruby on Rails sitemap plugin"

I have created a plugin named Dynamic Sitemaps that enables you to easily create flexible, dynamic sitemaps in Ruby on Rails. It generates sitemaps in the sitemaps.org standard which is supported by several crawlers including Google, Bing, and Yahoo. If the sitemap has more than 50.000 urls – or whatever you set it to using per_page – the plugin will automatically split the sitemap into smaller chunks and generate a sitemap index as specified at sitemaps.org.


To install in Rails 3:


rails plugin install git@github.com:lassebunk/dynamic_sitemaps.git


In config/initializers/sitemap.rb:


Sitemap::Map.draw do

  # default page size is 50.000 which is the specified maximum at http://sitemaps.org.
  per_page 10

  url root_url, :last_mod => DateTime.now, :change_freq => 'daily', :priority => 1

  new_page!

  Product.all.each do |product|
    url product_url(product), :last_mod => product.updated_at, :change_freq => 'monthly', :priority => 0.8
  end

  new_page!

  autogenerate  :products, :categories,
                :last_mod => :updated_at,
                :change_freq => 'monthly',
                :priority => 0.8

  new_page!

  autogenerate  :users,
                :last_mod => :updated_at,
                :change_freq => lambda { |user| user.very_active? ? 'weekly' : 'monthly' },
                :priority => 0.5

end


In config/routes.rb:


match 'sitemap' => 'sitemaps#sitemap'


You are now able to access your sitemap at http://yourdomain.com/sitemap.xml.


In public/robots.txt:


Sitemap: http://yourdomain.com/sitemap.xml


And at last submit it to Google, Bing, and Yahoo.


Check out the plugin at GitHub.

"Ruby on Rails sitemap plugin"

"3 Free Open Source E-Commerce for Ruby on Rails"

Ruby On Rails is an open source Web framework that help you to create web applications more easier, faster & write beautiful code by favoring convention over configuration. Here is 3 Free Open Source E-Commerce for Ruby on Rails
1. Spree

Spree is the open-source e-commerce platform  based on Ruby on Rails platform which is highly extensible & customizable. Spree follows RESTful design which makes the code easier to maintain for experienced Rails developers. Developers can easily override existing views, provide new ones or provide additional models, migrations and controllers. Spree  is maintained by an active team of developers who continue to refine the code based on lessons learned from the challenges of real world deployments. Best of all, Spree is completely free, the open source code is freely available and is licensed under the New BSD License.



Feature


  • Extensible Design
  • Spree supports the latest version of Ruby on Rails.
  • Simple and easy way to Upgrades
  • Unobtrusive Javascript
  • Custom Shipping Logic
  • Over 50 Payment Gateways Supported
  • Single Page Checkout
  • Advanced Inventory Features
  • Blueprint and Sass framework supported
  • Search Engine Friendly
  • & much more..

Demo  http://spreecommerce.com/demo
Download  http://spreecommerce.com/


2.  Substruct

Substruct is a open source e-commerce project written in Ruby on Rails framework. It provides a simple e-commerce platform, content management system and customer response system – all in one. its Cleanly designed, easy to extend and maintain. Substruct The first and most robust Ruby on Rails open source e-commerce project.



Feature :


* A simple content management system with blogging capabilities

o Manage your entire site’s content from the web – no html necessary!

* A simple shopping cart that’s tied into Authorize.net and PayPal (must have an account)

* Product and order management

o Track your inventory online

o View up to the minute sales reports

o Integrate with fulfillment houses via XML and web services

* A stunning administration interface

o Create and maintain content

o Create, maintain, void orders

o Answer questions from your visitors


Demo : http://substruct.subimage.com/
Download  http://code.google.com/p/substruct/


3. EcomPages


EcomPages is an open source shopping cart software written in Ruby on Rails. This beta release is an introduction version that gives user a general idea of how EcomPages works. More complex features will be added based on user’s discussion. And feel free to modify the code to fit your need. To install Ecompages you required Mac OS, Windows, Linux , Ruby on Rails 2.0.2 + and MySQL 4 + , Rmagick.



Download :http://github.com/colinm/ecompages-cm 

"3 Free Open Source E-Commerce for Ruby on Rails"

"25 Free Open Source eCommerce Platforms"

Electronic commerce, commonly known as e-commerce or eCommerce, or consists of the buying and selling of products or services over electronic systems such as the Internet and other computer networks. The amount of trade conducted electronically has grown extraordinarily with widespread Internet usage. Its very existence has allowed countless number of businesses reach new heights, and take advantage of endless possibilities. As new standards, ideas, and applications for eCommerce role out, the strength of your online presence must support these new trends.


Here is 25 Free Open Source eCommerce platform Applications we have found on the internet and select the one that’s right for you, your business and your customers.



  1. Magento – Magento is classified as an open source eCommerce platform that eases the flow between design and online sales. Magento is one of the fastest growing eCommerce solutions in the market, and with their long list of features it’s not hard to see why. Magento likes to out-smart other content management systems for eCommerce by providing excellent options to grow your site. Magento is a very flexible eCommerce platform that lets you Manage multiple websites, integrate Google Website Optimizer and over 50 payment gateways.
  2. PrestaShop – PrestaShop is a free, open source eCommerce platform that delivers a wide variety of features such as the full control of your inventory, orders, shipping and tracking, allowing you to manage your business in real-time. This eCommerce platform has a WYSIWYG editing tool for your products and the managing of images. Your online store can be customized at any time, accept PayPal payments, and manage customer based subscriptions. PrestaShop can send payments directly to your bank account, or your PayPal account.
  3. osCommerce – osCommerce has attracted a large growing e-commerce community that consists of over 228,200 store owners and developers who support each other and extend osCommerce Online Merchant with add-ons being contributed on a daily basis. To date there are over 5,800 add-ons that are available for free to customize osCommerce Online Merchant online stores and to help increase sales.
  4. Zen Cart – Zen Cart Free and straightforward, using Zen Cart falls within the capabilities of almost everyone. Besides the standard features you’d expect, Zen Cart offers a newsletter manager, discount coupons, quantity discounts, gift certificates and the ability to select exactly which cards you accept. There are tons of contributions to the software at your disposal with many from osCommerce preinstalled. This does make the admin interface a little cluttered for my liking though.
  5. CubeCart – CubeCart , the standard edition, is completely free to download and use. It comes complete with three different skins, customer order history, unlimited products, categories and images, multi-currency support, and product search. CubeCart 4, which costs over $100, comes with enhanced SEO, visitor skin selector, courier tracking URL, superior product search, and the ability to add and edit orders from the back-end. Both integrate well with any site and are suitable for those already selling online or preparing to open a shop. If you’re not familiar with PHP and MySQL, however, you might find setting up CubeCart on your own quite a challenge.
  6. VirtueMart – VirtueMart can’t operate alone: it’s an ecommerce solution designed to be used alongside the Joomla! CMS (content management system). In terms of a cart, it offers the complete package and it’s great from the shoppers’ point of view. Shoppers can register for an account, add addresses and view their order history with a minimum of fuss. VirtueMart supports multiple languages and currencies and you can add an unlimited number of products and product categories. Your products are searchable and can be rated by users. Despite its obvious strengths, it does have some minor weaknesses, including a somewhat poorly structured forum and some messy code here and there.
  7. Ubercart – VirtueMart can’t operate alone: it’s an ecommerce solution designed to be used alongside the Joomla! CMS (content management system). In terms of a cart, it offers the complete package and it’s great from the shoppers’ point of view. Shoppers can register for an account, add addresses and view their order history with a minimum of fuss. VirtueMart supports multiple languages and currencies and you can add an unlimited number of products and product categories. Your products are searchable and can be rated by users. Despite its obvious strengths, it does have some minor weaknesses, including a somewhat poorly structured forum and some messy code here and there.
  8. Avactis – Avactis, available as a free version or for a fee, integrates seamlessly with your existing website. Its web based help manual, video tutorials and setup wizard are sufficient for most people to install and manage without the help of expert developers. Advanced features include newsletter management, marketing and sales reports which you can export to Excel, multiple storefronts, numerous payment methods including Maestro, the ability to export accounting data to QuickBooks and support for tax systems around the world. To make the most of every feature out-of-the-box, you’re going to have to pay $19.95 per month or a one-off payment of $199, which seems reasonable. There are additional charges, however, for hosting your cart, support, updates and installation (if you can’t do that yourself). The shopper experience is smooth, but a little drawn out, as customers must navigate through various pages before paying for their goods.
  9. AgoraCart – AgoraCart is not as popular as some of the other platforms reviewed here and we’re not quite sure why. It’s flexible and fully customisable, great for setting up simple stores or complex design concepts. Insofar as design goes, you can choose from one of the templates on offer or design your own using CSS. Layouts and product categories can be tweaked to your heart’s content. In some ways, AgoraCart seems to have been left behind by some of the newer PHP based platforms, so is perhaps best suited to hobbyist coders.
  10. OXID eShop – OXID eSales is an open source e-commerce application built with PHP & uses MySQL for storing the data.
  11. Digistores – Digistore’s based on osCommerce, so will be instantly recognisable to anyone who’s ever used that ubiquitous ecommerce platform. It’s a full CMS, very quick and easy to install and can be operated by people with little or no coding knowledge. There are a number of free templates available to use, but if you like, you can buy a sleeker template or even have your own personal one created for a small fee. You can manager and alter colours, site width, layout and template from within the admin area and even run multiple adverts to promote your products.
  12. Spree – Spree, an ecommerce platform based on Ruby on Rails, is constantly growing and improving thanks to its active development team. There are loads of great extensions on offer which you can use to tailor your site to your specific needs. Spree lets you modify shipping, tax, discounts and coupons to suit your customers, who will themselves be more than satisfied with the single page checkout. It’s search engine friendly and has Google Analytics built in. It’s ideal for small and medium enterprises, but not the best choice for sites receiving the very highest levels of traffic.
  13. Freeway – Freeway allows you to manage your store using web-based administration interface. Built-in SEO tools will help attracting more visitors from search engines and increase your sales. Freeway is scalable, it will grow with your internet business so you can sell how you want to sell adding new functionality with ease.
  14. PHPshop – PHPshop‘s primary purpose of phpShop is to provide a simple shopping cart solution that is easy to customize to suit any purpose. phpShop has less features that many other shopping cart applications, but is generally easier to customize.  We were recently informed the PHPshop  is no longer active and is now under the name VirtueMart.
  15. OpenCart – Open cart’s admin area has a well designed user interface that simplifies the process of tweaking your site. When you first begin using this eCommerce platform you’re given a customizable layout that gives your products an adequate amount of “breathing room”. OpenCart lets you take full control of your shipping features and the ability to take coupons. You can use coupon codes for your existing customers as incentives. Open Cart is ideal for small to medium sized businesses that are looking for flexibility and the power of useful tools at their fingertips.
  16. WHMCS – WHMCS is an all-in-one client management, billing &  support solution for online businesses. WHMCS handles everything from signup to termination, with automated billing, provisioning & management. With WHMCS, you’re in control with a very powerful business automation tool.  Great Software, it runs our Sales and Hosting Platform at RackWire.com.
  17. TomatoCart – TomatoCart is an open source e-commerce application that is branched from the popular osCommerce to offer a better experience. It comes with a totally new front and back-ends where the back-end is an impressive desktop-like ExtJS-powered interface.
  18. eCart – eCart is an open source e-commerce shopping cart application that is built with PHP-MySQL. It is a fresh but powerful software which can manage multiple stores from a single admin interface, supports unlimited product categories, one-page-checkout and more.
  19. CS-Cart – CS-Cart is a complete shopping cart application that can quickly enable any business to start selling online whether it is a single-product shop or a complete marketplace. The application uses Ajax in many parts to ease usage and offers an overall smart logic for a better shopping experience like one-page checkout, featured/related products for cross selling and many more.
  20. ZeusCart – ZeusCart is an open source e-commerce application that is built with PHP and MySQL. The application has support for selling any type of items (including digital goods) where items can have multiple properties like color, size and multiple images.
  21. CRE Loaded PCI CE – CRE Loaded PCI CE is an open source e-commerce software which is the lighter, but still strong, version of a paid solution. It is designed to run on a LAMP (Linux, Apache, MySQL, PHP) server and offers lots of features which you can add more as it comes with the source.
  22. dashCommerce – dashCommerce is an open source e-commerce software developed with ASP.NET & using Microsoft SQL Server 2005 for storing data.
  23. osCSS – osCSS is simply a php eCommerce shopping application that’s built on the oscommerce GPL code. It’s available for a free download and distribution. This version complies with current web standards by using XHTML 1.1 as the mark-up language. You’ll have full take on how to display your products and the way they will be shipped. Although osCSS isn’t the most popular or powerful eCommerce CMS, it sure does get the job done.
  24. WP e-Commerce – WP e-Commerce is a Web 2.0 application designed with usability, aesthetics, and presentation in mind.  The WP e-Commerce shopping cart plugin for WordPress is an elegant easy to use fully featured shopping cart application suitable for selling your products, services, and or fees online
  25. Übercart – Übercart is an e-commerce suite developed for Drupal. With the end user in mind, focusing on usability at store configuration, product – catalog creation and order administration, Übercart is a simple yet powerful shopping cart solution.

Compliments to blogupstairs.com

"25 Free Open Source eCommerce Platforms"

"Finally a Twitter FOllow Button"

We’ve wanted this for ages, and our requests has been answered. According to the Twitter blog, the site has finally added a Follow button:

For publishers and brands, adding the Follow Button to your website and using Twitter to stay connected with your audience is a powerful combination. People who follow your account are much more likely to retweet and engage with your Tweets, and to repeatedly visit your website. Adding the Follow Button to your website is quick and easy, and you can configure yours right now at twitter.com/followbutton.

The follow button is being launched on 50 blogs around the Internet as of right now. If you want one for yourself, it’s incredibly easy to do. Just head to the link mentioned above and fill in the form. You’ll get a box of code on the right which you can then copy and paste into your desired location on your site.

"Finally a Twitter FOllow Button"