Accessing an arbitrary action in rails -
i confused how access action in rails controller not associated 1 particular model. routing file, default, seems routing action name "id". if type, say, /user/login, end error says: "couldn't find user 'id'= login"
what proper way access arbitrary action names in rails?
make route it, obviously. request goes way:
- first hits route
- from there hits controllers' action
- [an action may invoke model] (optional, common)
- controller specified view , fetches data render
- view sent in response request
resource
, resources
might not obvious do. in fact, shorthands corresponding collections of routes used quite often, this resources
adds. , they're not monoliths, can customised fit needs. providing options start, can provide block define custom action routes resource so:
resources :users :login end
this add /users/login
route maps userscontroller#login
, following rails' conventions.
see guide more details , don't forget run rake routes
see have @ moment.
Comments
Post a Comment