Application.html.erb in rails 4 -
i new rails 4.0.2 . working on application rails version 4 , ruby 2. in views application.html.erb file not working. not replicating on view files.
this code in application.html.erb file:
<!doctype html> <html> <head> <title>myapp</title> <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= csrf_meta_tags %> </head> <body> <%= yield %> </body> </html>
i have controller named xyz_controller.rb has following code:
class xyzcontroller << applicationcontroller end
the application_controller.erb file has following code:
class applicationcontroller < applicationcontroller def login end end
the login.erb file contains normal html code.
thanks in advance.
your application controller should this:
class applicationcontroller < actioncontroller::base # prevent csrf attacks raising exception. # apis, may want use :null_session instead. protect_from_forgery with: :exception end
your xyz controller should this:
class xyzcontroller < applicationcontroller def action #here define instance variables used in view action end ... end
... login
action, instance, defined there.
your view should named action.html.erb, action matches controller action , file should in app/views/xyz.
the rails mantra convention on configuration. means lot easier if (very closely) follow rails conventions naming, etc. recommend working way through tutorial hartl's if haven't already.
hope helps.
Comments
Post a Comment