2013-07-23 2 views
0

내가 HAML에서보기를 표시 노력 해왔다 문제가 있지만, 저를 던졌습니다 :레일, Mongoid, 쿼리를 돌려줍니다 문서

Started GET "/tipocontenidos/index" for 127.0.0.1 at 2013-07-23 17:22:36 -0500 
Processing by TipocontenidosController#index as HTML 
    MOPED: 127.0.0.1:27017 COMMAND  database=admin command={:ismaster=>1} (30.4270ms) 
    MOPED: 127.0.0.1:27017 QUERY  database=cms_monrails_development_crud_bd collection=ctipocontenido selector={} flags=[:slave_ok] limit=0 skip=0 batch_size=nil fields=nil (82.3016ms) 
    Rendered tipocontenidos/index.html.haml within layouts/application (126.7ms) 
Completed 500 Internal Server Error in 187ms 

ActionView::Template::Error (undefined method `tipocontenido_path' for #<#<Class:0x000000026ee6f8>:0x000000027c4528>): 
    8: 
    9: - @tipocontenidos.each do |tipocontenido| 
    10:  %tr 
    11:  %td= link_to 'Show', tipocontenido 
    12:  %td= link_to 'Edit', edit_tipocontenido_path(tipocontenido) 
    13:  %td= link_to 'Destroy', tipocontenido, :method => :delete, :data => { :confirm => 'Are you sure?' } 
    14: 
    app/views/tipocontenidos/index.html.haml:11:in `block in _app_views_tipocontenidos_index_html_haml__2795259947167794129_19628380' 
    app/views/tipocontenidos/index.html.haml:9:in `_app_views_tipocontenidos_index_html_haml__2795259947167794129_19628380' 
    app/controllers/tipocontenidos_controller.rb:7:in `index' 


    Rendered /home/stivenson/.gem/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms) 
    Rendered /home/stivenson/.gem/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms) 
    Rendered /home/stivenson/.gem/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (7.1ms) 

이 내 컨트롤러는, (내가 함께이 컨트롤러를 생성 "scaffold_controller") :

class TipocontenidosController < ApplicationController 
    # GET /tipocontenidos 
    # GET /tipocontenidos.json 
    def index 
    @tipocontenidos = Tipocontenido.all 

    respond_to do |format| 
     format.html # index.html.erb 
     format.json { render json: @tipocontenidos } 
    end 
    end 

    # GET /tipocontenidos/1 
    # GET /tipocontenidos/1.json 
    def show 
    @tipocontenido = Tipocontenido.find(params[:id]) 

    respond_to do |format| 
     format.html # show.html.erb 
     format.json { render json: @tipocontenido } 
    end 
    end 

    # GET /tipocontenidos/new 
    # GET /tipocontenidos/new.json 
    def new 
    @tipocontenido = Tipocontenido.new 

    respond_to do |format| 
     format.html # new.html.erb 
     format.json { render json: @tipocontenido } 
    end 
    end 

    # GET /tipocontenidos/1/edit 
    def edit 
    @tipocontenido = Tipocontenido.find(params[:id]) 
    end 

    # POST /tipocontenidos 
    # POST /tipocontenidos.json 
    def create 
    @tipocontenido = Tipocontenido.new(params[:tipocontenido]) 

    respond_to do |format| 
     if @tipocontenido.save 
     format.html { redirect_to @tipocontenido, notice: 'Tipocontenido was successfully created.' } 
     format.json { render json: @tipocontenido, status: :created, location: @tipocontenido } 
     else 
     format.html { render action: "new" } 
     format.json { render json: @tipocontenido.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # PUT /tipocontenidos/1 
    # PUT /tipocontenidos/1.json 
    def update 
    @tipocontenido = Tipocontenido.find(params[:id]) 

    respond_to do |format| 
     if @tipocontenido.update_attributes(params[:tipocontenido]) 
     format.html { redirect_to @tipocontenido, notice: 'Tipocontenido was successfully updated.' } 
     format.json { head :no_content } 
     else 
     format.html { render action: "edit" } 
     format.json { render json: @tipocontenido.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # DELETE /tipocontenidos/1 
    # DELETE /tipocontenidos/1.json 
    def destroy 
    @tipocontenido = Tipocontenido.find(params[:id]) 
    @tipocontenido.destroy 

    respond_to do |format| 
     format.html { redirect_to tipocontenidos_url } 
     format.json { head :no_content } 
    end 
    end 
end 

그리고 이것은 내 모델입니다 : 내가 함께 일하고

class Tipocontenido 
    include Mongoid::Document 
    store_in collection: "ctipocontenido" 

    field :nombretipo, type: String 
    belongs_to :aparienciacontenido 
    embeds_many :seccion 
end 

:

,
  1. 루비 1.9.3p448
  2. 레일 3.2.13
  3. 레이크 버전 10.1.0
  4. MongoDB의 쉘 버전 : 2.2.3

내가 돈 3.1.2 mongoid ' 나는이 콜렉션 "ctipocontenido"의 MongoDB 데이터베이스에 문서를 생성 했으므로이 오류를 이해하지 못합니다.

> db.ctipocontenido.find().pretty() 
{ 
     "_id" : ObjectId("51edfd3fddbc8d2622000001"), 
     "nombretipo" : "Colores Suaves 3 partes", 
     "seccion" : [ 
       { 
         "_id" : ObjectId("51edfd3fddbc8d2622000002"), 
         "nombre" : "Encabezado", 
         "color" : "#e5e5e5", 
         "borde" : "1px solid red", 
         "etiqueta" : [ 
           { 
             "_id" : ObjectId("51edfd3fddbc8d2622000003"), 
             "texto" : "Título", 
             "tipoletra" : "Verdana", 
             "tamanioletra" : "7", 
             "colorletra" : "#000000" 
           }, 
           { 
             "_id" : ObjectId("51edfd3fddbc8d2622000004"), 
             "texto" : "Lema", 
             "tipoletra" : "Verdana", 
             "tamanioletra" : "6", 
             "colorletra" : "#000000" 
           } 
         ] 
       }, 
       { 
         "_id" : ObjectId("51edfd3fddbc8d2622000005"), 
         "nombre" : "Panel Izquierdo", 
         "color" : "#e5e5e5", 
         "borde" : "1px solid red", 
         "etiqueta" : [ 
           { 
             "_id" : ObjectId("51edfd3fddbc8d2622000006"), 
             "texto" : "Título", 
             "tipoletra" : "Verdana", 
             "tamanioletra" : "7", 
             "colorletra" : "#000000" 
           }, 
           { 
             "_id" : ObjectId("51edfd3fddbc8d2622000007"), 
             "texto" : "Lema", 
             "tipoletra" : "Verdana", 
             "tamanioletra" : "6", 
             "colorletra" : "#000000" 
           } 
         ] 
       } 
     ] 
} 

그리고 이것은 내 보석 파일입니다

source 'https://rubygems.org' 

gem 'rails', '3.2.13' 
gem 'execjs' 
gem 'therubyracer' 
gem 'sass' 
gem "haml", '3.1.4' 
gem 'haml-rails' 
gem "mongoid", ">= 3.1.2" 
gem 'rake' , '10.1.0' 
gem 'rails3-generators' 


# rails generate model Book --skip-migration --orm=mongomapper 
# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 



# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'jquery-ui-rails' 
    # gem 'jquery-ui-themes', '0.0.7' 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes 
    # gem 'therubyracer', :platforms => :ruby 

    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 

# To use ActiveModel has_secure_password 
# gem 'bcrypt-ruby', '~> 3.0.0' 

# To use Jbuilder templates for JSON 
# gem 'jbuilder' 

# Use unicorn as the app server 
# gem 'unicorn' 

# Deploy with Capistrano 
# gem 'capistrano' 

# To use debugger 
# gem 'debugger' 

PD : 제 영어 실례!

대단히 감사드립니다. :)

답변

1

잘못된 장소를 찾고 있습니다. 오류는 귀하의 config/routes.rb 파일에 문제가 있음을 말합니다. Rails가 컨트롤러의 show 메소드와 일치하는 URL을 파악할 수 없습니다.

은 분명히 rails generate scaffold_controllerroutes.rb 편집 할 수 없습니다, 그래서 당신은 손으로해야하고 다음 코드를 추가합니다 : http://guides.rubyonrails.org/routing.html#listing-existing-routes

:

resources :tipocontenidos 

레일 여기 라우팅 디버깅하는 훌륭한 도구가있다

라우팅에 대한 자세한 정보 : http://guides.rubyonrails.org/routing.html