This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - Add in Gem file | |
| gem devise | |
| - Install devise | |
| $ rails generate devise:install | |
| - Generate user model and routes | |
| $ rails generate devise user | |
| - Add extra fields |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://rails-bestpractices.com/posts/48-use-openstruct-when-advance-search | |
| class Tableless | |
| include ActiveModel::Validations | |
| include ActiveModel::Conversion | |
| extend ActiveModel::Naming | |
| def initialize(props = {}) | |
| props.each do |name, value| | |
| send("#{name}=", value) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= form_for OpenStruct.new(:message => ''), :url => ... do |f| %> | |
| <%= f.text_field :message %> | |
| <% end %> | |
| # config/initializers/open_struct_extensions.rb | |
| class OpenStruct | |
| def respond_to?(symbol, include_private = false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Accessing Helper modules in rails | |
| http://www.funonrails.com/2010/12/accessing-helper-modules-in-rails.html | |
| 1. Helper methods all the time for views | |
| class ApplicationController < ActionController::Base | |
| helper :all# include all helpers, all the time for views | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('#cities') | |
| .textext({ | |
| plugins : 'autocomplete tags ajax prompt', | |
| prompt : 'Enter a city or town', | |
| ajax : { | |
| url : DrumBeatGlobals.get_cities_url, | |
| data : {country : 'US' }, | |
| dataType : 'json', | |
| loading : { message : 'Loading...'} | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Description | |
| * Author: Amitesh Kumar ([email protected]) | |
| * Date: 20th May, 2012 | |
| * | |
| */ | |
| /** | |
| * Module to display social info about a place | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Place all the behaviors and hooks related to the matching controller here. | |
| // All this logic will automatically be available in application.js. | |
| /** | |
| * Module for SampleWebApp Application | |
| * @author : Amitesh Kumar | |
| * | |
| */ | |
| ( function( $ ){ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Device wise apps : | |
| <pre> | |
| <%= JSON.pretty_generate(JSON.parse(@info.to_json)) %> | |
| </pre> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT default_character_set_name FROM information_schema.SCHEMATA S | |
| WHERE schema_name = "database_name"; | |
| show FULL columns from table_name; | |
| For Schemas: | |
| SELECT default_character_set_name FROM information_schema.SCHEMATA S | |
| WHERE schema_name = "schemaname"; | |
| For Tables: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| desc "convert a latin1 database with utf8 data into proper utf8" | |
| task :convert_to_utf8 => :environment do | |
| puts Time.now | |
| dryrun = ENV['DOIT'] != '1' | |
| conn = ActiveRecord::Base.connection | |
| if dryrun | |
| def conn.run_sql(sql) | |
| puts(sql) | |
| end | |
| else |