Thursday, 31 March 2016

Database Commands:
  • db:migrate runs (single) migrations that have not run yet.
  • db:create creates the database
  • db:drop deletes the database
  • db:schema:load creates tables and columns within the (existing) database following schema.rb
  • db:setup does db:create, db:schema:load, db:seed
  • db:reset does db:drop, db:setup
Typically, you would use db:migrate after having made changes to the schema via new migration files (this makes sense only if there is already data in the database). db:schema:load is used when you setup a new instance of your app.
I hope that helps.

UPDATE for rails 3.2.12:
I just checked the source and the dependencies are like this now:
  • db:create creates the database for the current env
  • db:create:all creates the databases for all envs
  • db:drop drops the database for the current env
  • db:drop:all drops the databases for all envs
  • db:migrate runs migrations for the current env that have not run yet
  • db:migrate:up runs one specific migration
  • db:migrate:down rolls back one specific migration
  • db:migrate:status shows current migration status
  • db:rollback rolls back the last migration
  • db:forward advances the current schema version to the next one
  • db:seed (only) runs the db/seed.rb file
  • db:schema:load loads the schema into the current env's database
  • db:schema:dump dumps the current env's schema (and seems to create the db as well)
  • db:setup runs db:schema:load, db:seed
  • db:reset runs db:drop db:setup
  • db:migrate:redo runs (db:migrate:down db:migrate:up) or (db:rollback db:migrate) depending on the specified migration
  • db:migrate:reset runs db:drop db:create db:migrate

Friday, 18 March 2016

Change root for logged in/Authenticated user:

  authenticated :user, ->(u) { u.has_role?(:seller) } do
    root to: 'dashboard#index', as: :authenticated_root
  end



Wednesday, 9 March 2016

Dump Mysql db that is compatible with postgresql also:
mysqldump -u username -p --compatible=postgresql databasename > outputfile.sql

Tuesday, 8 March 2016

You can create your own actions, decorators, support objects, and services for neat & clean code:

Thursday, 3 March 2016

Edit/Update dynamic data like best in place by Phrasing-

Installation

Include the gem in your Gemfile
gem "phrasing"
Bundle the Gemfile
bundle install
Run the install script which will create a migration file and a config file.
rake phrasing:install
Migrate your database
rake db:migrate

Setup

The rake task will also generate phrasing_helper.rb in your app/helpers folder. Here you will need to implement the can_edit_phrases? method. Use this to hook-up your existing user authentication system to work with Phrasing.
For example:
module PhrasingHelper

  def can_edit_phrases?
    current_user.is_admin?
  end

end
Include the phrasing html initializer at the top of your application layout file.
= render 'phrasing/initializer'
Include the required javascript file:
//= require phrasing
Include the required stylesheet file:
*= require phrasing

How to use phrasing?

You can start adding new phrases by simply adding them in your view file:
= phrase('my-first-phrase')
Aside from editing phrases (basically, Rails translations) you can also edit model attributes inline. Use the same phrase method, with the first attribute being the record in question, and the second one the attribute you wish to make editable:
= phrase(@post, :title)
In the above example, @post is the record with a title attribute.


or Follow https://github.com/infinum/phrasing