Edit Form won't show up: need advice

5 views
Skip to first unread message

François Beausoleil

unread,
Jan 4, 2010, 10:06:10 PM1/4/10
to Hobo Users
Hi all!

NOTE: all inline code below also viewable at https://gist.github.com/596e7e9992f42fba9b2d

I have some models (Person, Company, Events, etc). Some show fields
on edit, others don't. I'm really flabbergasted at what's going on
here. Company shows the form just fine, while Event and Person
don't. And I really am browsing http://localhost:3000/people/1/edit
and http://localhost:3000/companies/1/edit.

I looked at #update_permitted?: they're identical between both models

class Company < AR::B
def update_permitted?
# also tried simply returning true from here
!acting_user.guest?
end

def view_permitted?(field)
true
end
end

I removed my form override in application.dryml:

<extend tag="form" for="Person">
<old-form merge>
<field-list: fields="first_name, last_name, email, address1,
address2, address3, city, postal_code, home_number, mobile_number"/>
</old-form>
</extend>

<extend tag="form" for="Company">
<old-form merge>
<field-list: fields="name, address1, address2, address3, city,
postal_code, main_number, fax_number, toll_free_number"/>
</old-form>
</extend>

I also removed app/views/people/edit.dryml. Even if I change
Person#update_permitted? to return true the form doesn't show any
fields.

The relevant part of the generated HTML looks like this:

<div class="section with-flash content">
<div class="section content-header">
<h2 class="heading">Modification de <span class="view
model::person:1"><a class="person-link" href="/people/1-bernier-
gilles"><span class="view person-name ">Bernier, Gilles</span></a></
span></h2>
<form method="post" action="/people/1-bernier-gilles"
class="button-to"><div><input name="_method" type="hidden"
value="delete" /><input class="button delete-button delete-person-
button" onclick="return confirm('Are you sure?');" type="submit"
value="Remove This Personne" /><input name="authenticity_token"
type="hidden" value="cbQSYOo60ECXCQXcMVlrxld7Vys9iQ65JAPbUGl3Iv4=" /></
div></form>
</div> <div class="section content-body">
<div class="section ">
<h3 class="heading">Employeurs</h3>
<div class="table-plus">
<div class="header"> <div class="search">
<form action="" class="search-form" method="get"><div
class="hidden-fields"></div></form>
</div>
</div>
<table>
<thead>
<tr class="field-heading-row">
<th class="company-heading">
<a class="column-sort company-heading-link" href="/
people/1/edit?sort=company">Entreprise</a>
</th>
</tr>
</thead>
<tbody>
<tr class="odd employee model::employee:1">
<td class="company-view">
<span class="view employee-company model::company:
1"><a class="company-link" href="/companies/1-groupe-canam-inc"><span
class="view company-name ">Groupe Canam Inc.</span></a></span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>

What did I not do which I should have? I'm pretty sure I'm missing
something very basic here. And yes, I did restart my server between
changes, and am running in development mode.

Thanks!
François

François Beausoleil

unread,
Jan 6, 2010, 2:59:19 PM1/6/10
to Hobo Users
Bump? Any ideas?

On 4 jan, 22:06, François Beausoleil <francois.beausol...@gmail.com>
wrote:
> Hi all!
>
> NOTE: all inline code below also viewable athttps://gist.github.com/596e7e9992f42fba9b2d


>
> I have some models (Person, Company, Events, etc).  Some show fields
> on edit, others don't.  I'm really flabbergasted at what's going on
> here.  Company shows the form just fine, while Event and Person
> don't.  And I really am browsinghttp://localhost:3000/people/1/edit

> andhttp://localhost:3000/companies/1/edit.

Matt Jones

unread,
Jan 6, 2010, 3:17:52 PM1/6/10
to hobo...@googlegroups.com

On Jan 4, 2010, at 10:06 PM, François Beausoleil wrote:

> Hi all!
>
> NOTE: all inline code below also viewable at https://gist.github.com/596e7e9992f42fba9b2d
>
> I have some models (Person, Company, Events, etc). Some show fields
> on edit, others don't. I'm really flabbergasted at what's going on
> here. Company shows the form just fine, while Event and Person
> don't. And I really am browsing http://localhost:3000/people/1/edit
> and http://localhost:3000/companies/1/edit.
>

Can you post / gist some of the controller code? The two checks that
could be eating the entire form (from rapid_forms.dryml) are:

- can_edit? on the object. This seems unlikely, as it hits the
permission methods you've defined and should give the same results.

- object_url(target, nil, :method => 'put') is somehow returning nil.
This can happen if the controller action isn't declared.

--Matt Jones

François Beausoleil

unread,
Jan 7, 2010, 3:23:16 PM1/7/10
to Hobo Users
Hey Matt, thanks for replying.

I added some debug code in my view. #can_edit? returns false, and
#object_url return nil.

I added my controller code to:

https://gist.github.com/596e7e9992f42fba9b2d#file_app_controllers_people_controller.rb

And that resolved my issue: I was under impression that #auto_actions
should be called with an :except for the methods we're going to
redefine. I thought Hobo would look at #instance_methods, not
#auto_actions, to determine which actions are really available.

I'm actually referring to: http://cookbook.hobocentral.net/manual/controllers#changing_action_behaviour

Quoting: "(Note: In the above example, we’ve asked for the default
index action and then overwrote it. It might have been neater to say
”auto_actions :all, :except => :index” but it really doesn’t matter.)"

Should this sentence be rewritten?

Thank you very much!
François

Matt Jones

unread,
Jan 7, 2010, 3:51:43 PM1/7/10
to hobo...@googlegroups.com

On Jan 7, 2010, at 3:23 PM, François Beausoleil wrote:

> Hey Matt, thanks for replying.
>
> I added some debug code in my view. #can_edit? returns false, and
> #object_url return nil.

> I added my controller code to:
>
> https://gist.github.com/
> 596e7e9992f42fba9b2d#file_app_controllers_people_controller.rb
>
> And that resolved my issue: I was under impression that #auto_actions
> should be called with an :except for the methods we're going to
> redefine. I thought Hobo would look at #instance_methods, not
> #auto_actions, to determine which actions are really available.

It's supposed to. Was the typo in the Gist (the 'update' method is
defined as 'udate') in the original source, or was that an accident
while cleaning things up to post?

can_edit? returning false is a little weird - what user are you logged
in as when that happens? Here's the chain of calls from can_edit?:

- can_edit? calls this.editable_by?(current_user, nil)
- this.editable_by? calls:
- viewable_by?(current_user, nil), which your code indicates will
always be true
- edit_permitted?(nil), with the acting user set
- which calls update_permitted?, which *should* be returning true

So I'm stumped as to why it'd end up returning false at any point...

--Matt Jones

François Beausoleil

unread,
Jan 8, 2010, 3:06:45 PM1/8/10
to Hobo Users
It's always the simple things.... Git tells me I had a #udate method
in PeopleController as well as EventsController: the two models with
which I had problems. I was supposed to be logged in as an
administrator, but I can't confirm now. I'd have to reinvestigate.

Thank you very much for your time!
François

Reply all
Reply to author
Forward
0 new messages