Ruby On Rails

    How to install blog in refinerycms

    To install blog in refinerycms follow these steps
    1.  Include refinerycms-blog in gemfile

    gem 'refinerycms-blog', '~> 1.6.2'

    2. Run bundle install

    ubuntu@rails$:  bundle install

    3. Next install blog plugin

    ubuntu@rails$: rails generate refinerycms_blog


    4. Run database migration

    ubuntu@rails$: rake db:migrate


    Done blog is installed sucessfully

    How to import wordpress pages and posts to refinerycms

    To import wordpress pages and posts to refinerycms Follow the steps: 1. First of all add gem "refinerycms-wordpress-import" to gemfile in rails gem 'refinerycms-wordpress-import', :git => 'git://github.com/mremolt/refinerycms-wordpress-import.git' 2. Run Bundle install rails $ bundle install 3. Next task is to export data from wordpress as xml file save the xmlfile to application root and run this is to add pages to refinerycms rails$ rake wordpress:reset_and_import_pages\[wordpress.xml\] 4.

    WARN TCPServer Error: Address already in use - bind(2) Exiting Ruby on Rails

    This problem is due to port already used or not properly stopped. To work this properly first find the process id and then kill it and start the server again Follow the steps your output come like this: 1. mohit@ubuntu:/home/app/alpha$ netstat -tulpn | grep :3000 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 8540/ruby 2. mohit@ubuntu:/home/app/alpha$ kill -9 8540 3.

    Invalid gemspec in [/var/lib/gems/1.8/specifications/ problem

    This is a date format problem with gems so to fix this run following command
      root@ubuntu$ sudo sed -i 's/ 00:00:00.000000000Z//' /var/lib/gems/1.8/specifications/*

    What is difference between form_for and form_tag in ruby on rails

    form_for is used for model fields and its assign proper actions on the basis of new post and edit post to the form

    Where form_tag is used in case when you have to render fields other than model or your custom fields form

    How to add blank data in select box in ruby on rails

    To show blank selection option in rails application form select use the code below where @agencies shows the whole list and :include_blank add a blank in dropdown
      

    <%= select_tag "agency", options_from_collection_for_select(@agencies, "id", "name", agency),  :style => "width:100px;", :include_blank => true, :selected => nil %>

    How to start script console in ruby on rails

    To start script console in ruby on rails use following commands

    Use ruby "script/console" for rails version earlier then 2.3.x

    User "rails console" for rails version 3.x

    Note: Don't use double quotes with the commands