mongodb - Rails, Mongoid, query: Not returns documents -


i have problem, have been trying show view in haml, throws me this:

started "/tipocontenidos/index" 127.0.0.1 @ 2013-07-23 17:22:36 -0500 processing tipocontenidoscontroller#index 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' #<#<class:0x000000026ee6f8>:0x000000027c4528>):     8:      9:   - @tipocontenidos.each |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 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) 

this controller, (i generated controller "scaffold_controller"):

class tipocontenidoscontroller < applicationcontroller   # /tipocontenidos   # /tipocontenidos.json   def index     @tipocontenidos = tipocontenido.all      respond_to |format|       format.html # index.html.erb       format.json { render json: @tipocontenidos }     end   end    # /tipocontenidos/1   # /tipocontenidos/1.json   def show     @tipocontenido = tipocontenido.find(params[:id])      respond_to |format|       format.html # show.html.erb       format.json { render json: @tipocontenido }     end   end    # /tipocontenidos/new   # /tipocontenidos/new.json   def new     @tipocontenido = tipocontenido.new      respond_to |format|       format.html # new.html.erb       format.json { render json: @tipocontenido }     end   end    # /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 |format|       if @tipocontenido.save         format.html { redirect_to @tipocontenido, notice: 'tipocontenido 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 |format|       if @tipocontenido.update_attributes(params[:tipocontenido])         format.html { redirect_to @tipocontenido, notice: 'tipocontenido 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 |format|       format.html { redirect_to tipocontenidos_url }       format.json { head :no_content }     end   end end 

and model:

class tipocontenido   include mongoid::document   store_in collection: "ctipocontenido"    field :nombretipo, type: string   belongs_to :aparienciacontenido   embeds_many :seccion end 

i working with:

  1. ruby 1.9.3p448
  2. rails 3.2.13
  3. rake version 10.1.0
  4. mongodb shell version: 2.2.3
  5. mongoid 3.1.2

i don't understand error, because have document create in mongodb database in collection "ctipocontenido":

> 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"                                 }                         ]                 }         ] } 

and gem file:

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 assets , not required # in production environments default. group :assets   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 more supported runtimes   # gem 'therubyracer', :platforms => :ruby    gem 'uglifier', '>= 1.0.3' end  gem 'jquery-rails'  # use activemodel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0'  # use jbuilder templates json # gem 'jbuilder'  # use unicorn app server # gem 'unicorn'  # deploy capistrano # gem 'capistrano'  # use debugger # gem 'debugger' 

pd: excuse english !!

thanks in advance !! :)

you're looking in wrong places. error saying there's wrong config/routes.rb file. rails not being able figure out url matches show method in controller.

apparently rails generate scaffold_controller not edit routes.rb, you'll have hand , add following code it:

resources :tipocontenidos 

there's great tool debug rails routing here: http://guides.rubyonrails.org/routing.html#listing-existing-routes

more routing: http://guides.rubyonrails.org/routing.html


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -