Rails CouchDB related models not seing each other -
having code :
models
paciente.rb
class paciente include simplystored::couch has_many :consultas end
consulta.rb
class consulta include simplystored::couch belongs_to :paciente end
controllers
consultas_controller.rb
class consultascontroller < actioncontroller::base layout "application" before_filter :get_paciente def get_paciente @paciente = paciente.find(params[:paciente_id]) end def index @consultas = @paciente.consultas.all end def new @consulta = @paciente.consultas.new end def create @consulta = consulta.create(params[:consulta]) if @consulta.save redirect_to(@consulta, :notice => 'consulta created.') else render :action => "new" end end end
routes
routes.rb
example::application.routes.draw resources :pacientes resources :consultas end end
error
i can't list consultas this.
/pacientes/very long paciente id couchdb style id/consultas
i can see @paciente object exists,(i can inspect it), can't reach consultas there.
because get:
nameerror in consultascontroller#index uninitialized constant consultum
on line :
@paciente.consultas.all <-- unable reach consultas
last couple of days been on , on this, btw using symplystored accessing couchdb; have tried specifying class name samee result , class name same name relationship.
thanks in advance clues !
salvador - rails makes assumptions pluralization rules, namely in english. while not familiar couchdb api in rails, appears nameerror rails attempting pluralize consultas
-> consultum
.
this blog post developer's experiences related non-english model names , activerecord ... chances are, you're running against same thing in activemodel -> simplystored::couch
Comments
Post a Comment