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
def routes | |
#... | |
@routes | |
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
if request_path =~ /^\articles$/ | |
#go to articles#index | |
elsif request_path =~ /^\recipes$/ | |
#go to recipes#index | |
elsif | |
# etc etc more looping ahh! | |
else | |
# route not found? | |
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
@routes || ActionDispatch::Routing::RouteSet.new |
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
#action_dispatch/routing/route_set.rb | |
@set ||= Journey.Routes.new |
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.application.routes.draw do | |
get '/login' => 'admin/sessions#new' | |
get '/logout' => 'admin/sessions#destroy' | |
namespace :admin do | |
resources :posts | |
resources :sessions, only: [:new, :create, :destroy] | |
resources :moderators, only: [:index, :edit, :update] | |
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
Prefix Verb URI Pattern Controller#Action | |
login GET /login(.:format) admin/sessions#new | |
logout GET /logout(.:format) admin/sessions#destroy | |
admin_posts GET /admin/posts(.:format) admin/posts#index | |
POST /admin/posts(.:format) admin/posts#create | |
new_admin_post GET /admin/posts/new(.:format) admin/posts#new | |
edit_admin_post GET /admin/posts/:id/edit(.:format) admin/posts#edit | |
admin_post GET /admin/posts/:id(.:format) |
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
siddhants-MacBook-Air:railsblog sid$ rails c | |
Loading development environment (Rails 5.2.3) | |
irb(main):001:0> scanner = ActionDispatch::Journey::Scanner.new | |
=> #<ActionDispatch::Journey::Scanner:0x00007f84f432d658 @ss=nil> | |
irb(main):002:0> scanner.scan_setup("moderators/:id") | |
=> #<StringScanner 0/14 @ "moder..."> | |
irb(main):003:0> scanner.next_token | |
=> [:LITERAL, "moderators"] | |
irb(main):004:0> scanner.next_token | |
=> [:SLASH, "/"] |
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
siddhants-MacBook-Air:railsblog sid$ rails c | |
Loading development environment (Rails 5.2.3) | |
irb(main):001:0> parser = ActionDispatch::Journey::Parser.new | |
=> #<ActionDispatch::Journey::Parser:0x00007fa630dce528 @scanner=#<ActionDispatch::Journey::Scanner:0x00007fa630dce4b0 @ss=nil>> | |
irb(main):002:0> syntax_tree = parser.parse("/moderators/:id(.:format)") | |
=> #<ActionDispatch::Journey::Nodes::Cat:0x00007fa633df05d0 @left=#<ActionDispatch::Journey::Nodes::Slash:0x00007fa633df1110 @left="/", @memo=nil>, @memo=nil, @right=#<ActionDispatch::Journey::Nodes::Cat:0x00007fa633df0648 @left=#<ActionDispatch::Journey::Nodes::Literal:0x00007fa633df0ff8 @left="moderators", @memo=nil>, @memo=nil, @right=#<ActionDispatch::Journey::Nodes::Cat:0x00007fa633df0698 @left=#<ActionDispatch::Journey::Nodes::Slash:0x00007fa633df0f08 @left="/", @memo=nil>, @memo=nil, @right=#<ActionDispatch::Journey::Nodes::Cat:0x00007fa633df06e8 @left=#<ActionDispatch::Journey::Nodes::Symbol:0x00007fa633df0cb0 @left=":id", @memo=nil, @regexp=/[^\.\/\?]+ |
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
{[200, {}, [“Hello World”]]} |
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
mix new dailyploy_project --umbrella | |
|-- apps | |
|-- config | |
| -config.exs | |
|-- mix.exs | |
|- README.md |
OlderNewer