This file contains 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
module KalpeshExtensions | |
def print *args | |
unless defined?(@log) | |
@log = Logger.new(Rails.root.to_s + "/log/custom.log") | |
@logger = Logger.new(Rails.root.to_s + "/log/#{Rails.env}.log") | |
end | |
puts "\n#{self.class.name}##{self.try(:action_name) rescue nil}\n#{'-' * 10} #{Time.now.strftime("%H:%M:%:S %P")} #{'-' * 10}" | |
@log.info "\n#{self.class.name}##{self.try(:action_name) rescue nil}\n#{'-' * 10} #{Time.now.strftime("%H:%M:%:S %P")} #{'-' * 10}" | |
@logger.info "\n#{self.class.name}##{self.try(:action_name) rescue nil}\n#{'-' * 10} #{Time.now.strftime("%H:%M:%:S %P")} #{'-' * 10}" |
This file contains 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
Testing | |
https://tomafro.net/2009/05/automatching-rails-paths-in-cucumber | |
http://asciicasts.com/episodes/155-beginning-with-cucumber | |
http://railsapps.github.io/tutorial-rails-devise-rspec-cucumber.html | |
Backbone | |
https://www.youtube.com/watch?v=FZSjvWtUxYk |
This file contains 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
class ApplicationController < ActionController::Base | |
%w(user category post comment).each do |name| | |
define_method "find_#{name}" do | |
obj = instance_variable_set("@#{name}", name.camelize.constantize.find_by_id(params[:id])) | |
unless obj | |
flash[:alert] = "#{name.camelize} not found" | |
respond_to do |format| | |
format.html{ redirect_to "/#{name.pluralize}" } | |
format.js{ render js: "window.location='/#{name.pluralize}'" } |
This file contains 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
# Postgres | |
development: | |
adapter: postgresql | |
encoding: utf8 | |
database: text_development | |
username: postgres | |
password: root | |
host: localhost | |
# Sqlite |
This file contains 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
# Create .irbrc file using touch | |
# $ touch ~/.irbrc | |
# Add following function to .irbrc file | |
def clear | |
system ‘clear’ | |
end | |
# Open IRB with | |
# $ irb |
This file contains 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://www.modrails.com/documentation/Users%20guide%20Nginx.html#install_on_debian_ubuntu | |
Instruction for Ubuntu 12.X (should work on 11.x also) | |
a. Installing passenger gem | |
$ gem install passenger | |
b. Installing passenger-nginx module(It will compile and install Nginx with Passenger support) | |
IF ruby is installed without RVM |
This file contains 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
Instruction for Ubuntu 12.X (should work on 11.x also) | |
a. Installing apache2 server | |
$ sudo apt-get install apache2 | |
Restarting apache | |
$ sudo /etc/init.d/apache2 restart | |
b. Installing passenger gem | |
$ gem install passenger |
NewerOlder