LadyBug
unread,Oct 27, 2009, 7:59:13 AM10/27/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Hobo Users
This may be more of a general Rails routing question but I have come
across an interesting problem.
In my test application I have a model, Project, and the associated
ProjectController. The controller has the following declarations and
they work just fine:
hobo_model_controller
auto_actions_for :owner, [:index, :new, :create]
auto_actions :destroy, :edit, :show
Now, I defined a totally new action in the controller, which basically
generates some default stuff for my project:
def new_default_model
...
end
And I put a link/button/whatever in my project table view to call that
new action, like this:
<controls:>
<a class="new-link" with="&this"
action="new_default_model" >New default model</a><br/>
<a class="edit-link" with="&this" action="edit" >Edit</
a><br/>
<delete-button label="Remove project" update="self" />
</controls:>
Now, what happens is that both the edit link and the delete button get
presented nicely, but the new_default_model action link is not. Just
text, no link. Ok, a routing issue then. I added:
map.project_new_default_model 'projects/:id/new_default_model',
:controller => 'projects',
:action => 'new_default_model',
:conditions => { :method => :get }
to my routes.rb. But this did not work. Just text is displayed, no
link (i.e. no <a> tag at all).
However, if I remove the above route and use Hobo to generate the
routing for me using in the ProjectController:
show_action :new_default_model
The link gets filled out as it should be.
I get exactly the same output line with "rake routes" using both of
these methods:
project_new_default_model GET /projects/:id/
new_default_model
{:action=>"new_default_model", :controller=>"projects"}
Hobo of course generates the .format route as well, but it should not
be the issue here?
The location of the above route is also different. Hobo places the
route in the middle of list among other Hobo routes. The manual
mapping places the line either on top or bottom of route list,
depending on the placement of the mapping line. Neither manual
placement (before or after Hobo mappings) works.
I have experimented with member routing as well, but the above
mentioned manual definition was the one producing exact match with the
Hobo route.
So, why does the Hobo show_action generate working routing and the
manual mapping doesn't?