I am trying to develop a plugin for Ruby on Rails and have run into problems rendering my html view. My directory structure looks like this:
File structure
|
|
|
|
|
|
|
|
|
|
|
|
|
In /rails/init.rb
require 'todo_lib'
In / lib / app / todo _lib.rb
%w{ models controllers views }.each do |dir|
path = File.expand_path(File.join(File.dirname(__FILE__), 'app', dir))
$LOAD_PATH << path
ActiveSupport::Dependencies.load_paths << path
ActiveSupport::Dependencies.load_once_paths.delete(path)
end
In todo / lib / app / controller / todos_controller.rb
class TodosController < ActionController::Base
def index
end
end
In todo / lib / app / views / index.html.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/url]">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Todos:</title>
</head>
<body>
<p style="color: green" id="flash_notice"><%= flash[:notice] %></p>
<h1>Listing Todos</h1>
</body>
</html>
In /myRailsApp/config/routes.rb
ActionController::Routing::Routes.draw do |map|
map.resources :todos
...
The error I am getting is the following:
Missing template
Missing todos / index.erb template in view / views of view path
Can someone give me a hand and tell me what I'm doing wrong here, which leads to the index.html.erb file not showing up? Really appreciate!
EDIT:
I have already tried the following without success:
In / todo / lib / app / controllers / todos _controller.rb
def index
respond_to do |format|
format.html
end
end
EDIT:
hakunin . .
, Rails ( , ), , :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:
todo/lib/todo_lib.rb
%w{ models controllers views }.each do |dir|
path = File.expand_path(File.join(File.dirname(__FILE__), '../app', dir))
$LOAD_PATH << path
ActiveSupport::Dependencies.load_paths << path
ActiveSupport::Dependencies.load_once_paths.delete(path)
end
: path = File.expand_path (File.join(File.dirname(FILE), '../app', )). [ "", ].
script/server index.html.erb todo/app/views/todos.