At any rate, yeah duh gee. Figured it out as soon as I actually looked
at the controllers, then updating them for DM, which I thought I did,
but didn't. Then I solved the main collection render by looking at the
template (which was just wrong wrong from the original repo I pulled
it from. So it works, it'll be up on github for anyone to reference,
hopefully I can add more to a demo.

On May 16, 12:34 pm, none1 <[email protected]> wrote:
> I'm just returning to this, put it aside for a while:
>
> Here is the entire controller for the documents
> --------------------------------------------------------------------
> class DocumentsController < ApplicationController
>
>   def index
>     @documentz = Document.all
>     respond_to do |format|
>         format.json {render :json => @documentz }
>     end
>     #render :json => Document.all
>   end
>
>   def show
>     @document = Document.find(params[:id])
>     respond_to do |format|
>         format.json {render :json => @document }
>     end
>     #render :json => Document.find(params[:id])
>   end
>
>   def create
>     #@document = Document.create(params)
>     document = Document.create! params
>     render :json => document
>   end
>
>   def update
>     document = Document.find(params[:id])
>     document.update_attributes! params
>     render :json => document
>   end
> end
>
> request, or what rails telling me it is seeing
> -------------------------------------------
>
> siteroot/#
>
> Started GET "/documents" for 127.0.0.1 at 2011-05-16 12:26:37 -0400
>   Processing by DocumentsController#index as JSON
>   SQL (0.050ms)  SELECT "id", "title", "body" FROM "documents" ORDER
> BY "id"
> Completed 200 OK in 5ms (Views: 2.4ms | Models: 0.050ms)
>
> siteroot/#documents/1
> Started GET "/documents/1" for 127.0.0.1 at 2011-05-16 12:28:25 -0400
>   Processing by DocumentsController#show as JSON
>   Parameters: {"id"=>"1"}
>   SQL (0.053ms)  SELECT "id", "title", "body" FROM "documents" ORDER
> BY "id"
> Completed   in 3ms
>
> NoMethodError (undefined method `call' for "1":String):
>   app/controllers/documents_controller.rb:16:in `block (2 levels) in
> show'
>   app/controllers/documents_controller.rb:15:in `show'
>
> In the js console we get the 'Uncaught TypeError: Cannot read property
> 'id' of undefined' that don't understand.
>
> Still beyond me although with your help, we can post new documents
>
> On May 3, 4:04 pm, Emmanuel Gomez <[email protected]> wrote:> On May 
> 3, 2011, at 8:34 AM, none1 wrote:
>
> > > That was exactly what I was unaware of.
>
> > > Documents can now be created by the form, but won't be shown. The js
> > > console gives this error:
>
> > > Uncaught TypeError: Cannot read property 'id' of undefined
>
> > Can you paste in the Rails controller methods? It looks like 
> > DocumentsController#index, #create... You know what, can you paste in your 
> > entire DocumentsController?
>
> > > so I'm getting one step closer -- thank you very much Emmanuel.
>
> > You're welcome.
>
> > > The model now looks like:
>
> > >    require 'dm-serializer'
> > >    class Document
>
> > >        include DataMapper::Resource
> > >        include DataMapper::MassAssignmentSecurity
>
> > >        property :id, Serial
> > >        property :title, String
> > >        property :body, String
>
> > >        attr_accessible :body, :title
>
> > >       #def to_json(options = {})
> > >       #  super(options.merge(:only =>
> > > [:id, :title, :created_at, :body]))
> > >       #end
>
> > > end
>
> > > - that to_json method still appears to do nothing I can detect (when
> > > uncommented)
>
> > The DocumentsController code will help clear this up.
>
> > > - going to /#documents/1
>
> > >   produces an interesting:
>
> > >   NoMethodError (undefined method `call' for "1":String):
>
> > Again, this is hard to interpret without a view of your controller code, 
> > and possibly the request params.
>
> > > I'll keep poking at it, thanks again.
>
> > Good luck, sounds like fun!
>
> > - Emmanuel

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to