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
# in config/environments/production.rb | |
Compass.configuration.sass_options={:never_update=>true} |
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
# Source: http://stackoverflow.com/questions/592554/best-way-to-create-custom-config-options-for-my-rails-app | |
# For general application configuration that doesn't need to be stored in a database table, I like to create a | |
# config.yml file within the config directory. For your example, it might look like this: | |
defaults: &defaults | |
audiocast_uri_format: http://blablalba/blabbitybla/yadda | |
development: | |
<<: *defaults |
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
# Ignore everything | |
/* | |
# Except .gitignore | |
!.gitignore | |
# Except for database, uploads, extensions and settings | |
!/mediawiki | |
mediawiki/* |
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://stackoverflow.com/questions/1992019/how-to-rename-a-database-column-in-rails-using-migration | |
# $ rails g migration FixColumnName | |
# db/migrate/xxxxxxxxxx_fix_column_name.rb | |
class FixColumnName < ActiveRecord::Migration | |
def self.up | |
rename_column :table_name, :old_column, :new_column | |
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
<?php | |
/** | |
* Also show custom post types in tag/category/archive pages | |
*/ | |
function query_post_type($query) { | |
if(is_category() || is_tag()) { | |
$post_type = get_query_var('post_type'); | |
if($post_type) { | |
$post_type = $post_type; | |
} else { |
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
<?php | |
/** | |
* Allow extra elements in TinyMCE | |
*/ | |
add_filter('tiny_mce_before_init', create_function( '$a', | |
'$a["extended_valid_elements"] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]"; return $a;') ); | |
?> |
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
# Test in test/functional/sites_controller_test.rb | |
test "should contain a valid url" do | |
@site.url = "random text" | |
assert @site.invalid? | |
end | |
# Implementation in app/models/site.rb | |
class Site < ActiveRecord::Base | |
validates_format_of :url, :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix | |
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
# Test in test/functional/sites_controller_test.rb | |
test "should be unique" do | |
link1 = sites(:one) | |
link1.save | |
link2 = Site.new(sites(:two)) | |
link2.url = link1.url | |
assert !link2.save, "Saved a link with the same url" | |
end | |
# Implementation in app/model/site.rb |
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
boy: | |
id: 1 | |
email: boy@email.com | |
encrypted_password: 4567554354 | |
sign_in_count: 10 | |
barry: | |
id: 2 | |
email: barry@email.com | |
encrypted_password: 4567554354 |
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 EventsControllerTest < ActionController::TestCase | |
setup do | |
@event = events(:one) | |
sign_in users(:boy) | |
end | |
end |