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
# What we had to do: | |
<% semantic_form_for @post do |form| %> | |
<%= form.inputs :title, :created_at %> | |
<% form.semantic_fields_for @post.author do |author_form| %> | |
<% author_form.inputs do %> | |
<%= author_form.input :name %> | |
<%= author_form.input :posts_count %> | |
<% end %> | |
<% end %> | |
<% 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
class ProjectsController < InheritedResources | |
def set_flash_message!(status, default_message) | |
message = if action_name == 'create' && status == :error | |
'This is a new message. Your project could not be created.' | |
else | |
default_message | |
end | |
flash[status] = message unless message.blank? | |
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
require 'autotest' | |
Autotest.add_hook :initialize do |at| | |
at.clear_mappings | |
# watch out: Ruby bug (1.8.6): | |
# %r(/) != /\// | |
at.add_mapping(%r%^spec/.*_spec.rb$%) { |filename, _| | |
filename | |
} | |
at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| |
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
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
describe TasksController do | |
mock_models :task | |
describe :get => :index do | |
expects :find, :on => Task, :with => :all, :returns => mock_task | |
should_assign_to :tasks, :with => mock_task | |
describe Mime::XML do |
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 ActiveRecord | |
module Generators | |
class ModelGenerator < Base | |
# Line below is optional. If the generator name would be :model, the name | |
# below could be guessed. | |
# | |
# Generators are also public by default. If they are private it can be | |
# invoked only by other generators. | |
# | |
name :activerecord, :private => false |
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
# COMMUNITY CHALLENGE | |
# | |
# How would you test this Quiz#problem method? Only two rules: | |
# | |
# 1. You must test the order the gets/puts happen. The tests should not | |
# still pass if "gets" happens before "puts", etc. | |
# | |
# 2. No changing the Quiz class implementation/structure. But you can | |
# use whatever framework you want for the tests. | |
# |
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 Remarkable | |
module Pending | |
# We cannot put the alias method in the module because it's a Ruby 1.8 bug | |
# http://coderrr.wordpress.com/2008/03/28/alias_methodmodule-bug-in-ruby-18/ | |
# | |
def self.extended(base) #:nodoc: | |
class << base | |
alias_method_chain :example, :pending |
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 Amazing < Thor::Group | |
include Actions | |
def self.source_root | |
end | |
def copy | |
copy_file "my_file" | |
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
# Rails Generators invocations types. | |
# | |
# = PROBLEM | |
# | |
# 1) Rails should provide hooks for other generators in other to | |
# provide agnosticism. | |
# | |
# 2) Plugins/gems should be able to hook into another generator even | |
# if a hook is not there. |