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
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" /> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<title>Resize a Marker</title> | |
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css" /> | |
<link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css" type="text/css" /> | |
<script src="http://openlayers.org/api/OpenLayers.js"></script> | |
<script type="text/javascript"> | |
var map, layer; |
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
# I'm not able to access the instance variable in my mailer view. I tried naming the instance variables as @xyz, @body_content but nothing worked | |
# broadcast_email.rb | |
class BroadcastEmail < ActionMailer::Base | |
default :from => "[email protected]" | |
def send_message(message) | |
@message = "some dummy text" | |
mail(:to => "[email protected]", :subject => "this is a subject") | |
end |
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
I have a table. 1st column is a column for checkboxes and 2nd column is normal data. | |
When I check a check a single box I get an alert due to the following function which is as expected. | |
//To catch events when check boxes are checked. | |
$('input:checkbox').live('change', function() { | |
alert("Checked!"); | |
}); | |
But when I check all checkboxes using the command below, I don't get the alert from the function above. |
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
#lib/time_filter.rb | |
module TimeFilter | |
def today | |
where("created_at >= ?", Date.today) | |
end | |
end | |
# In Rails Console | |
>> include TimeFilter |
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
Consider a simple blogging app on Rails. Lets say, I have a list of articles, and I'd like to filter them by today's articles and this week's articles. | |
I'd like to define two methods in the model that does the actual filtering. | |
class Article < ActiveRecord::Base | |
def self.this_week | |
Article.where("created_at > ?", Date.today.beginning_of_week) | |
end | |
def self.today |
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
#This file should be config/setup_load_paths.rb | |
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') | |
begin | |
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME'])) | |
rvm_lib_path = File.join(rvm_path, 'lib') | |
$LOAD_PATH.unshift rvm_lib_path | |
require 'rvm' | |
RVM.use_from_path! File.dirname(File.dirname(__FILE__)) | |
rescue LoadError |
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
namespace :assets do | |
task :rebuild do | |
# Config the base names of all the jammit CSS packages you have defined | |
# in assets.yml. Could probably parse assets.yml to get this if | |
# we wanted to. | |
packages = ['common'] | |
# This is because on OS X, you have to put an explicit empty string to the | |
# required extension argument with the -i parameter, but on Linux you | |
# do not. |
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
<% content_for :head do %> | |
<title><%= @current_city.site_name %> : <%= @current_city.name %> Governance Observatory : Homepage</title> | |
<% end %> | |
<div class = 'main-content'> | |
<!-- Some content --> | |
</div> | |
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
# Rails 3 Config | |
# | |
# In: config/application.yml | |
# | |
# development: | |
# github: | |
# key: test | |
# secret: verysecret-dev | |
# production: | |
# github: |
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 APPNAME | |
class Application < Rails::Application | |
config_file = YAML.load_file("#{Rails.root}/config/settings.yml") | |
global = config_file['global'].symbolize_keys | |
config.settings = global.merge( config_file[Rails.env].symbolize_keys ) | |
# Use: APPNAME::Application.config.settings[:setting_var] | |
end |
OlderNewer