Edit action for Owner ?

25 views
Skip to first unread message

Vivek Sampara

unread,
Nov 8, 2012, 10:53:56 AM11/8/12
to hobo...@googlegroups.com
Hi guys, 

Im trying to create a table plus for Model B in Model A 

<show-page>
  <content-body:>
    <a with="&this.MODELAs" action="new" >New Snippet</a>
    <table-plus with="&this.MODELAs" fields="content" >
    <controls: />
    </table-plus>
  </content-body:>
</show-page>

but i get this new style url  does not match old style url /MODELAs//edit. 

I could create a Model A object for Model B  but not able to have an edit action for that particular object . 

any idea how to get the controls for Model A objects via Owner actions on table-plus ?

Thanks
Vivek 

Bryan Larsen

unread,
Nov 8, 2012, 11:22:19 AM11/8/12
to hobo...@googlegroups.com
It looks like this.MODELAs is returning some models that don't exist
in the database or have a nil id for some other reason.

You can only have an edit action for items that exist in the database.

Bryan
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/0jwC1msA5FMJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.

Vivek Sampara

unread,
Nov 8, 2012, 11:35:14 AM11/8/12
to hobo...@googlegroups.com
Thats right. 

Its more like parent child relation 

child has actions :all
actions_for :parent , [:index, :create, :new ] 

So some children are created explicitly without a parent id and some with parent id . 

Im trying to put a table plus for those which dont have a parent id with controls. 

Can correct if im doing anything wrong here ? 

Thanks
Vivek 

Bryan Larsen

unread,
Nov 8, 2012, 11:51:21 AM11/8/12
to hobo...@googlegroups.com
I'm definitely still missing something. Can you recreate your
problem on a sample application so I can play around with it to figure
out exactly what's going on?

It appears that _id_ is nil. parent_id being nil shouldn't be causing
this type of error. There is really no reference to modelb inside of
the table-plus...

thanks,
Bryan

Vivek Sampara

unread,
Nov 8, 2012, 12:43:08 PM11/8/12
to hobo...@googlegroups.com
You're right. I messed up an association . I created the parent from admin controller and the user_id became admin user_id , no the actual user :) 

Any idea why it might crash when i try to have controls in the table plus ? 

<show-page>
  <content-body:>
    <a with="&this.children" action="new" >New Child</a>
    <table-plus:children  fields="this" >
        <controls: />
    </table-plus>
  </content-body:>
</show-page>


new style url  does not match old style url /snippets//edit. obj: #<Snippet id: nil, name: nil, content: nil, created_at: nil, updated_at: nil, user_id: 2, style: nil, multisnippet_id: 1, template_id: nil>.  args: ["edit", {"subsite"=>nil}].  backtrace: ["/home/raven/.rvm/gems/ruby-1.9.3-p286@hobo20/gems/hobo_rapid-2.0.0.pre3/taglibs/html/a.dryml:147:in `block in a'", "/home/raven/.rvm/gems/ruby-1.9.3-p286@hobo20/gems/dryml-2.0.0.pre3/lib/dryml/template_environment.rb:379:in `block in _tag_context'", "/home/raven/.rvm/gems/ruby-1.9.3-p286@hobo20/gems/dryml-2.0.0.pre3/lib/dryml/template_environment.rb:281:in `block in new_context'",
multisnippet is the parent and snippet is the child 

multisnippet has_many snippets 
snippet belongs to multisnippet

New link is working perfectly and the parent_id is getting assigned correctly . but table plus crashes when i add controls 

Thanks
Vivek

Bryan Larsen

unread,
Nov 8, 2012, 12:52:09 PM11/8/12
to hobo...@googlegroups.com
From your backtrace, it's crashing on a snippet that doesn't have an id:

`#<Snippet id: nil`

What's your definition of `children`? Can you inspect `this.children`
to see if it contains any elements with id: nil? Does it work if you
use `table-plus:snippets` rather than `table-plus:children`?

Bryan

Vivek Sampara

unread,
Nov 8, 2012, 12:56:51 PM11/8/12
to hobo...@googlegroups.com
yup im using table-plus:snippets 

heres my console 

1.9.3p286 :037 > Snippet.all

  Snippet Load (0.6ms)  SELECT "snippets".* FROM "snippets" 
 => [#<Snippet id: 1, name: "Events", content: "Test events Admin Change", created_at: "2012-10-31 02:16:29", updated_at: "2012-10-31 02:24:45", user_id: 2, style: "", multisnippet_id: nil, template_id: nil>,

 #<Snippet id: 2, name: "first event", content: "First Event", created_at: "2012-11-08 15:43:03", updated_at: "2012-11-08 17:31:29", user_id: 2, style: nil, multisnippet_id: 1, template_id: nil>,

 #<Snippet id: 3, name: "Event 2", content: "Event 2 ", created_at: "2012-11-08 15:54:28", updated_at: "2012-11-08 17:30:58", user_id: 2, style: nil, multisnippet_id: 1, template_id: nil>,

 #<Snippet id: 4, name: "Normal Snippet", content: "Normal Snippet", created_at: "2012-11-08 16:16:43", updated_at: "2012-11-08 16:16:43", user_id: 2, style: "", multisnippet_id: nil, template_id: nil>] 

1.9.3p286 :038 > 

theres no snippet without an id 

Vivek
Reply all
Reply to author
Forward
0 new messages