Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/ninsho/rails/routes.rb

Instance Method Summary collapse

Instance Method Details

#ninsho_on(resources_name) ⇒ Object

Includes the ninsho_on method for routes. This method is responsible for creating all the routes needed.

Example

Assuming you have an authentications model on your application, your routes should look like:

ninsho_on :authentications

This method will generate something like:

Session routes
new_authentication_session_path GET /sign_in { controller: 'ninsho/sessions', action: 'new' }
    authentication_session_path POST /authentication/:provider/callback { controller: 'ninsho/sessions', action: 'create' }
destroy_authentication_session_path DELETE /sign_out { controller: 'ninsho/sessions', action: 'destroy' }


22
23
24
25
26
27
# File 'lib/ninsho/rails/routes.rb', line 22

def ninsho_on(resources_name)
  drawer = Ninsho::RoutesDrawer.new resources_name
  Ninsho.resource_class = drawer.to
  Ninsho.resource_name = drawer.resource
  ninsho_session(drawer.singular_name)
end