How to add views to a controller in a ruby on rails application manually(not through controller wizard)? -
i using ruby mine building ruby on rails application. working fine. create new project , press ctrl+alt+g. generator option choose controller. window in have name controller , actions. when select different actions, corresponding functions created in controller named after actions. if press icon left of functions name view file opened particular function having extension.html.erb.this fine. if forget add 1 or more action in controller dialog box. supposedly have add function name view want. i.e.
def functionname end
now when click on left of functionname. option create file of extension .html.erb. of working fine. when build application , try access newly created view following error`
routing error no route matches [get] "/say_hello/sona" try running rake routes more information on available routes.
how can add views controller except using controller wizard??can't add view afterwards?? `
i don't know wizard access url in application need:
route
defined in config/routes.rb
, in case:
get 'say_hello/sona', to: 'your_controller#your_action'
controller
defined in app/controllers/your_controller.rb
class yourcontroller < applicationcontroller def your_action end end
template or view
defined in app/views/your_controller/your_action.html.erb
, leave file empty, has created.
Comments
Post a Comment