Last active
August 29, 2015 14:17
-
-
Save 1syo/378aa00ae72d5f10b692 to your computer and use it in GitHub Desktop.
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
# config/initializers/constraints.rb | |
class Home | |
def matches?(req) | |
req.params[:id] #=> nil | |
# ..... | |
end | |
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
# app/controllers/home_controller.rb | |
class HomeController < ApplicationController | |
def show | |
render text: params[:id] | |
end | |
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
# spec/routing/home_routing_spec.rb | |
require 'spec_helper' | |
describe 'routes to the home controller' do | |
it 'routes /home/1 to home#show' do | |
get('/home/1').should route_to controller: 'home', action: 'show', id: '1' | |
end | |
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
# config/routes.rb | |
Spike::Application.routes.draw do | |
get "home/:id" => 'home#show', constraints: Home.new | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
4.2.0
は OK